Well several ways to do it, though I try to avoid using parenting, as if you ever do any 2.5d games, it can really get in the way. One trick to do what you want is to make an actor, and make it invisible, but allow events. This actor should be lower zdepth than anything within the view, but you can parent everything that needs to follow the screen around to that. All actors parented to this new actor will have higher zdepth, but you can make them all relative to each other, so your shadow can be lower. Again, you might note some problems with this if you have a background that is not supposed to move with this actor.
Another way is to use an absolute placement from an actor. This actor would be the equivalent of the parent actor, as all actors that would be parented to it have some code similar to what I have below. Again this has its ups, but it isn't all that optimal.
- Code: Select all
x=referenceActor.x+100;
y=referenceActor.y-50;
The last thing I'll suggest is to right an equivalent to a moveto function, that moves all the actors you want it to. So lets say if all of your actors you are supposed to follow an actor, player, than whenever player moves you would use the function. The following is what it might look like in global code.
- Code: Select all
void
MoveActors (int xspeed, int yspeed)
{
player.x+=xspeed;
player.y+=yspeed;
view.x+=xspeed;
view.y+=yspeed;
hpDisp.x+=xspeed;
hpDisp.y+=yspeed;
}
Of course you might want to make it better suited for your game, but the idea is still there. If you want a demo of any of these or you have any questions, just ask.