Detect side click of actor
ErikAuranaune
Member Posts: 35
Hi, how can i detect witch side of the actor i press? I want that the more to left i click, the bigger motion.linear.velocity.x it gets.
So if i press all on the left on the actor it moves example motion.linear.velocity.x = 100, and if i press in the middle of the actor, it moved motion.linear.velocity.x = 0. Something like that.. Any suggestions?
Comments
(With a 100 x 100 pixel actor)
When touch is pressed Change Velocity:
Direction: 0
Speed: max(0,min(100,(100-( game.Mouse.Position.X - self.Position.X )*2)-100))
I tried this, but it only makes it move right. How do i do this also with right side?
Try reversing it?
Mathtap.com (Android) | Fridgemanager.com (Android) | Breakoutofspace.com (Android)
How exactly? It doesn´t work for me.
Lol I worked the expression out to precisely match your stated aims.
"if i press all on the left on the actor it moves example motion.linear.velocity.x = 100, and if i press in the middle of the actor, it moved motion.linear.velocity.x = 0."
It was actually quite tricky trying to get the maths to ignore the righthand side of the actor and only respond to the left - I wish people wouldn't approach questions in a piecemeal fashion ! The reason it only moves right is because that's what you asked for.
I could give you the answer, but I suspect at that stage you will tell me that your actor is not 100 x 100 pixels, I would then change the expression to work with the size of your actor, at which stage you will tell me that the actor needs to rotate . . . (etc etc)
Play around with this . .
When touch is pressed and mouse position is inside
Change velocity to:
Direction 0
Speed ((100-( game.Mouse.Position.X - self.Position.X ))-100)*2
Actually, my actor is 100 x 100 pixels
Then speed = ((100-( game.Mouse.Position.X - self.Position.X ))-100)*2 should work !!
Yes, i used:
Speed = ((100-( game.Mouse.Position.X - self.Position.X ))-100)*10
Thanks for all the feedback, you've been a pleasure to work for Lol.
Haha, thanks for the good help mate!