Implementing player movement

  • barabasandras1
    Likes 0

    Problem Description

    My question is what is the best way to implement the movement for a sprite. It should behave like: when you touch the screen on a certain point the sprite will go there in n second it doesnt matter now. But if you keep touching (onTouchMoved?) the screen, it should follow your finger always. I made an action MoveTo with the touch.getLocation parameters but it keeps bouncing so its shitty as hell. 

  • Sonar Systems admin
    Likes 0

    Could you show us a video of what happens please.

  • barabasandras1
    Likes 0

    Sorry, I can’t. I try to explain it.

    Make a sprite, then create a new event listener where you are listening the main layer. When you’re moving your finger the screen, the sprite you created should follow it by an action you trigger every time the event happens. The action is MoveTo(). That’s it. It will go crazy.

    I just want this simple thing. The sprite should follow my finger on the screen :)

  • Sonar Systems admin
    Likes 0

    Have you cancelled all previous actions to prevent multiple from occuring at the same time?

  • barabasandras1
    Likes 0

    No I haven’t. Do you think this would be the problem here?

  • Sonar Systems admin
    Likes 0

  • barabasandras1
    Likes 0

    I will check it out. Thanks in advance! :D You’re a life saver guys rly


    This reply has been verified.
  • Sonar Systems admin
    Likes 1

    :D      

  • barabasandras1
    Likes 1

    Well :D its not bugging/bouncing anymore but still it doesnt follow my finger :( only when i stop touching the screen

    All right I managed to solve this by making a simple solution: i just use sprite.setPosition() when I call the onTouchMoved :D No need to use any actions if i want it to follow my touch...


    This reply has been verified.
  • Sonar Systems admin
    Likes 1

    Great to hear you have it solved :D

Login to reply