Touch movement on X-axis with animation

fozkulfozkul Member Posts: 27
edited October 2012 in Working with GS (Mac)
Hello everyone,

I have a quick question. I have an actor on the screen and I want it to move only on X axis with a touch.

I got the actor mimicking the same exact movement of the finger on X axis.


So far I got everything working, but i have a little problem.

This is how i got it done:
I created 2 real attributes, initialTouchX and offsetX

When touch count is 1

change initialTouchX to game.touches.touch1x
change offsetX to initialTouchX-positionx
constrain positionX to game.touches.touch1.x-offsetX

It works really smooth. The actor exactly follows the finger touch.

So let me tell the problems i'm having.
I need my actor to animate, because there is no motion or velocity, I cant get it working. I tried to add motion, max speed and bunch of other stuff but didn't help. So what is the correct way to add animation to this actor?

Another problem is I have bunch of other actors, following the main actor (the one moves with touch) However, the movement of the following actors seems to be delayed. I got them moving by constraining the self position to the position of the main actor. Is there a way to fix this delay?

I really appreciate your help guys!

Best Answer

Answers

  • GLGAMESGLGAMES SingaporeMember Posts: 988
    any screenshot of what you did? you want your actor to move to your touch position or constrain the actor to your touch position and drag it around the x axis?
  • fozkulfozkul Member Posts: 27
    Hi Glgames, thank you for your quick respond. I have a sample template that you can download,

    https://www.dropbox.com/sh/h36vs3u483pxm52/Qn6vV9ybUx


    As you can see on the template, you can touch anywhere on the screen, and while it's pressed and as you move the touch, the actors will move along as well. Until this point everything works but i can't add an animation since there is only a position change ( no velocity or motion )Consequently I can't make a rule saying when velocity is higher than zero do this animation. I tried to approach with different ways but couldn't figure it out. What should be the approach to this problem?

    Thanks again
  • fozkulfozkul Member Posts: 27
    Anybody?
  • fozkulfozkul Member Posts: 27
    Anybody please?
  • fozkulfozkul Member Posts: 27
    BUMP
Sign In or Register to comment.