Change image animation while flying around with touch controls

Rogue AnvilRogue Anvil Member, PRO Posts: 30

Am trying to get a little space shooter running. I'd like to change the animations rolling sideways when moving the finger left and right on the screen. Right now I am just moving the spaceship sprite around using constrain x and y:

I have a notion that one could simply try a rule saying something like if touch 1 x is > 1 (or < -1 if right) do changeimage, but it is not working... any ideas?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2018

    There are probably better ways to do this but here's what I came up with. The self.previousX attribute is type real. I start with an image of a rocket facing up. FYI, it's a Mac file but you should be able to open it on a PC. In case you can't, here are the rules that I added to the constrain behaviors you had:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Rogue AnvilRogue Anvil Member, PRO Posts: 30

    Thanks, this works very well! ...am using animation instead of rotation, but your thinking solved my problem. Thank you :)

  • CasualEvolutionCasualEvolution Member, PRO Posts: 537

    Hi @Rogue Anvil you can use the "Motion Linear Velocity" sign, and flip the image according to this :)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @CasualEvolution said:
    Hi @Rogue Anvil you can use the "Motion Linear Velocity" sign, and flip the image according to this :)

    Correct me if I'm wrong but a constrained actor has no velocity.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • CasualEvolutionCasualEvolution Member, PRO Posts: 537

    @tatiang said:

    @CasualEvolution said:
    Hi @Rogue Anvil you can use the "Motion Linear Velocity" sign, and flip the image according to this :)

    Correct me if I'm wrong but a constrained actor has no velocity.

    Ups!, I not have idea if works with a constrained actor, he should check that!

Sign In or Register to comment.