Hi, say I have some points (evenly spaced) on screen [-16, -12, -8, -4, 0, 4, 8, 12, 16] and I have an entity that is feely movable... how can I snap the position of the entity to the nearest number once the user has finished moving the joystick? So for example, if the entity was moved to 10.5 how do I get this to measure the difference between entity position and the two nearest numbers I have specified, and then position the entity to the nearest one? There has to be a tidy way of doing this, without having to manually check everything each time the joystick is moved! Thanks!
|