How do I round player x to the closest of 4 positions

Get help using Construct 2

Post » Wed Oct 08, 2014 10:51 am

When I press the right or left arrow I want the sprite to go to the closest of the 4 x positions given. Lets say player.x = 360 and the 4 positions are (100,120,150,300) I want player.x to move to 300. I already have a expression that rounds it to the closest factor of 80 which is: round(Player.X /80)*80 but when I wrap the sprite it does not round.

Thankyou and I hope you can help
B
8
S
3
G
2
Posts: 52
Reputation: 1,762

Post » Wed Oct 08, 2014 7:31 pm

Function object to the rescue !

First parameter is the value to match to the closest between all other parameters.
You do not have the required permissions to view the files attached to this post.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Lancifer, Yahoo [Bot] and 13 guests

cron