Animate when there is a change in self.positionX
Hello
I have an actor following the movement of a touch on X axis. It basically constraints its position.X to touch.1.X
Im having a problem animating this actor. Im trying to animate when the actor changes its position(move), either left or right.
I've been trying to figure this out for a week now. So far, I got two different approaches. First one, the actor moves just like i want, it moves smooth but doesn't animate correctly. My second approach, the actor animates just perfect, but doesn't move smooth (It doesn't mimic the movement of the touch)
This is the first approach game project, please take a look.
In the project, as you can see the animation won't stop when the actor stops.
https://www.dropbox.com/sh/h36vs3u483pxm52/Qn6vV9ybUx
With another approach I got everything working, it animates perfect. However, with this approach, it doesn't exactly mimics the swipe of the finger like in the first project.
This is the second approach game project.
https://www.dropbox.com/sh/kxf2w10t6rrq398/KiciDlLSKs
Take a look at both and you will see the differences of the movements.
Thank you!!
I have an actor following the movement of a touch on X axis. It basically constraints its position.X to touch.1.X
Im having a problem animating this actor. Im trying to animate when the actor changes its position(move), either left or right.
I've been trying to figure this out for a week now. So far, I got two different approaches. First one, the actor moves just like i want, it moves smooth but doesn't animate correctly. My second approach, the actor animates just perfect, but doesn't move smooth (It doesn't mimic the movement of the touch)
This is the first approach game project, please take a look.
In the project, as you can see the animation won't stop when the actor stops.
https://www.dropbox.com/sh/h36vs3u483pxm52/Qn6vV9ybUx
With another approach I got everything working, it animates perfect. However, with this approach, it doesn't exactly mimics the swipe of the finger like in the first project.
This is the second approach game project.
https://www.dropbox.com/sh/kxf2w10t6rrq398/KiciDlLSKs
Take a look at both and you will see the differences of the movements.
Thank you!!
Answers
If the touch.1.x is greater than self.position.x you know it will be going right, and if the touch.1.x is less than self.position.x you know it will be going left.
From this info you can tell the animation to animate left or right.
The more detail you give the easier it is to describe what needs to be done.
My problem is the animation. I don't know if you have seen the animation on the first example, it is not working right ( Actually I couldn't implement it right). The animation is not working smooth as the second project.
On the second project, the actor animates perfect but it doesn't really follow the finger, it constraints speed of the touch instead of its position.
So what i really wanna do is, I want my actor to move as in 1st project and animate like in the 2nd project.
Thanks Again!!
Make an attribute (type=real): oldX
When game.Touches.Count = 1
-- Animate Behavior
-- Timer every 0 seconds
---- Change Attribute self.Position.X To: game.Touches.Touch 1.X
---- When game.Touches.Touch 1.X > self.oldX
------ Change Attribute self.Graphics.Flip Horizontally To: false
------ Change Attribute self.oldX To: game.Touches.Touch 1.X
---- When game.Touches.Touch 1.X < self.oldX
------ Change Attribute self.Graphics.Flip Horizontally To: true
------ Change Attribute self.oldX To: game.Touches.Touch 1.X
it partially works.
It keeps animating as long as the touch is pressed still.
I actually want to animate when there is a position change
Animate Behavior
Timer every 0 seconds
--Change Attribute self.Position.X To: game.Mouse.Position.X
--When game.Mouse.Position.X > self.oldX
----Change Attribute self.Graphics.Flip Horizontally To: false
----Change Attribute self.oldX To: game.Mouse.Position.X
--When game.Mouse.Position.X < self.oldX
----Change Attribute self.Graphics.Flip Horizontally To: true
----Change Attribute self.oldX To: game.Mouse.Position.X
This time it animates when it stands still. So I think I have to put this animate behavior into some kind of a rule
Constrain Attribute: self.Motion.Linear Velocity.X To:(game.Mouse.Position.X-self.Position.X)*25
When self.Motion.Linear Velocity.X > 3
-- Animate Right
When self.Motion.Linear Velocity.X < -3
-- Animate Left
When self.Motion.Linear Velocity.X >-3 (AND) self.Motion.Linear Velocity.X < 3
-- Change image (monkey_1)
I think this is closer to having the monkey stand still like you want.
But i have another problem with this
My actor is collidable with some other actors, when it collides it's gonna make my actor bounce. I want it to be stable. That's why i was trying to implement with position change instead of velocity change, so I could set it to not movable.
But i guess with this method, i can just give a density of 5000+, so my actor wont move when it collides with my other actors.
Thanks a bunch!!!