edited November 2014 in Help request
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:

AnimationList = CatWalkUp#

LinkList = CatWalkUpLoop#

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;
     if (!player1.moving)
        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??


  • edited November 2014
    CatWalkLeftLoop is not an animation so you can't call it with orxObject_SetTargetAnim. The loop is a link.

    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:, 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:
    Source      = WalkRight
    Destination = WalkRight
    Source      = WalkRight
    Destination = IdleRight
    Property    = immediate; <= If you remove this property, the animation won't be cut to go immediately back to idle
    Priority    = 9
    ; Our idle animation is only one frame here, that lasts for 0.05s
    KeyData1      = AnimRight6
    KeyDuration1  = 0.1
    Source      = WalkRight
    Destination = WalkRight

    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.
  • edited November 2014
    Actually, this was built by studying the tutorial. Would you be so kind as to look at this? This is my catwalkleft.ini file which is included after the other I posted:
    ;First, we need to define an animation set that will contain the whole graph for our specific object's animations.
    [[email protected]]
    Texture     = ../data/catwalk-0.png
    [[email protected]]
    Texture     = ../data/catwalk-1.png
    [[email protected]]
    Texture     = ../data/catwalk-2.png
    [[email protected]]
    Texture     = ../data/cat-idle-left.png
    KeyData1      = CatAnimLeft4
    KeyDuration1  = 0.1
    DefaultKeyDuration  = 0.3
    KeyData1            = CatAnimLeft1
    KeyData2            = CatAnimLeft2
    KeyData3            = CatAnimLeft3
    KeyData4            = CatAnimLeft2
    Source      = CatIdleLeft
    Destination = CatIdleLeft
    Property    = immediate;  <= If you remove this property, the animation won't be cut to go immediately back to idle
    Source      = CatWalkLeft
    Destination = CatWalkLeft
  • edited November 2014
    oops, I left this out. I could put the whole thing here but it's getting quite large.

    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
  • edited November 2014
    That seems ok, I think the only thing missing is telling the graph how to get to walk, and how to get to idle:
    Source      = CatIdleLeft 
    Destination = CatWalkLeft 
    Source      = CatWalkLeft 
    Destination = CatIdleLeft 

    That should sort it out.

    If not, maybe post the whole thing and I'll dig through.
Sign In or Register to comment.