This cat game has 4 animations, left, right, up, down. I've tested them individually and all work just fine. However, if I place them all in the game I never get but one to execute. And, that one that does is the first one in the animation list. Like this:
[CatAnimSet]
AnimationList = CatWalkUp#
CatIdleUp#
CatWalkDown#
CatIdleDown#
CatWalkLeft#
CatIdleLeft
LinkList = CatWalkUpLoop#
CatIdleUpLoop#
CatWalkDownLoop#
CatIdleDownLoop#
CatWalkLeftLoop#
CatIdleLeftLoop
With it like that CatWalkUp will always be executed no matter what I do. Here's some code for switching:
else if (orxInput_IsActive("Moveright"))
{
player1.dir = plrRT;
orxObject_GetPosition(player1.obj,&player1.pos);
player1.pos.fX+=2;
orxObject_SetPosition(player1.obj,&player1.pos);
if (!player1.moving)
{
orxObject_SetFlip(player1.obj,orxTRUE,orxFALSE);
eResult = orxObject_SetTargetAnim(player1.obj, "CatWalkLeftLoop");
player1.moving = orxTRUE;
}
}
Now, the cat will actually move in the correct direction on MoveRight, but the animation it executes stays the same.
What am I doing wrong here??
Comments
The link tells the current animation where to go when it finishes.
In the case of CatWalkLeftLoop, when the CatWalkLeftAnim animation finishes, do CatWalkLeftAnim again.
Also, you don't need to do orxObject_SetFlip, you can just add Flip in your config.
I reckon take another look at offical tutorial 4: http://orx-project.org/wiki/en/orx/tutorials/anim, also the code and ini that goes with them are in the tutorial and also in the orx you have downloaded.
So basically, every animation needs to have a path to go to another animation when it finishes, even if it's just an idle like:
Takes a bit to get your head around at first, but once you do, the possibilities are huge, and the headache of complex animation switching is taken care of. No code needed.
[catObject]
Graphic = catGraphic
AnimationSet = CatAnimSet
Position = (0.0, 140.0, -0.2)
Pivot = top left
Scale = (2.0,2.0,0.0)
;Color = (255, 0, 0)
;Alpha = 0.0
Rotation = 0
Body = catBody
That should sort it out.
If not, maybe post the whole thing and I'll dig through.