Touch 1 actor multiple times

Hi, I'm working on my first app (for ipad) and can't seem to figure out 1 (probably simple) thing. If I want an actor to have 3 things he can do, for example; on first touch jump and land, on second touch wave arms and on the third touch to do a pirouette (all animated). The first touch i get, but what rule do I have to create so the actor goes to the second and third animation?

I hope i'm clear in my problem :)

Thanks a bunch

Comments

  • DaftbombDaftbomb Member Posts: 36

    Hey there. I'm very new to this so it might be a fail on my part but I have an idea.

    Try creating an attribute "step" for the actor (integer)that acts as a step counter and set it to 0.

    Then if actor receives a touch and step = 0 change self. Image to the first frame of jump animation and set step to step+1.

    Have a separate rule that starts the jump animation if self.image is this starting image. Finally increase step by 1 when self.image is the last frame of animation.

    Do this all two more times for when step = 2 and 4 (but set step to 0 once self. Image is final frame of third animation routine)

    So hopefully, an animation routine will only start if the step is 0,2 or 4 and it does them in order.

    Hopefully this helps, I can imagine there's many more efficient ways but that's what I'd try.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    Create attribute called game.state (number att of some sort)

    when touch is pressed
    Change attribute game.state  to mod(game.state+1,3)
    

    The values will rotate between 0,1,2. So now create rules off of that

    when game.state =0
    
    do animation 1
    
    When game.state=1
    
    do animation 2
    
    When game.state=2
    
    do animation 3
    

    If you want the animations to finish before the player can trigger the next you'll want to either detect the last frame of the animation by using self.image or by using a timer that syncs with the animation length. This should control a variable such as a boolean (game.animationcomplete we'll say)

    So now:

        when touch is pressed and
        game.animationcomplete is true
        Change attribute game.state  to mod(game.state+1,3)
    
        when game.state =0 
        change game.animationcomplete to false
        do animation 1
        timer after x seconds change game.animationcomplete to true 
    

    Follow us: Twitter - Website

  • Thanks! this helps me out a lot!
    I can go on with the game now :)

Sign In or Register to comment.