TorqueX/PlatformerFrameworkEnhancements
From TDN
[edit]
Introduction
These are simple modifications to extend the platformer framework.
[edit]
Killing the actors
Currently the actors in the starter kit are not being deleted off the level, and are being marked as hidden. This was to allow the actors to re-spawn if needed. If your game has more complex actors that fire bullets for example, they will continue to fire even when there dead and not visible! Below is one method of getting around this issue.
In ActorAnimationManger.cs >> Actor animation states >> DieState >> Execute you will see the following lines:
f (!actorAnimMgr._actorComponent._animatedSprite.IsAnimationPlaying)
actorAnimMgr._actorComponent._actor.Visible = false;
This needs to be changed to:
if (!actorAnimMgr._actorComponent._animatedSprite.IsAnimationPlaying)
{
if (actorAnimMgr._actorComponent.Actor.TestObjectType(PlatformerData.SpawnedObjectType))
{
CheckpointSystemSpawnedObjectComponent spawned = actorAnimMgr._actorComponent.Actor.Components.FindComponent<CheckpointSystemSpawnedObjectComponent>();
if (spawned != null)
spawned.Recover = false;
actorAnimMgr._actorComponent.Actor.MarkForDelete = true;
}
else
{
actorAnimMgr._actorComponent.Actor.Visible = false;
}
}
[edit]
The wall or ceiling?
Sometimes you may want to know whether a actor has hit the wall or the ceiling. The easiest way of doing this is in your Controller >> ActorHitWall
public override void ActorHitWall(ActorComponent actor, T2DCollisionInfo info, float dot)
{
base.ActorHitWall(actor, info, dot);
// if we aren't moving away from the normal flag _hitWall as true
if (dot <= 0 && info.Normal.X != 0)
{
_hitWall = true;
}
else if (dot <= 0 && info.Normal.Y != 0)
{
_hitCeiling = true;
}
}
//fields
protected bool _hitCeiling;
Make sure to reset the ceiling variable!



