Hello,
I am using a controller to move a sprite (vehicle) around. I want to create in the middle of the screen a rectangle that the sprite can not penetrate when the rectangle is visible.
Currently, i use tilebackground to create a rectangle, and a button on the control makes toggles it visibility.
To move the sprite i use the joystick on the control -- e.g. if its pressed right i increase the sprites X location by 5, and similarly in the other directions( right decrease by 5, up -- decreate Y by 5, down increase y by 5).
This works great to move the sprite around.
To test whether whether i can move over the rectangle i test for overlap between the sprite the the tilebackground.
However, here i run into a problem -- once the sprite overlaps with the rectangle its essentially jumped into it (due to the increase of 5) -- and then can not move out of it anymore.
What i intended was that it can not get into there in the first place -- the incremenets (or decrements) are stopped.
Is there a better way to move a sprite via a joystick or to test for overlap so that the overlap never happens.
(I am now thinking that i need to test the X+/-5 Y+/- 5 coordinate before moving that many units -- and thereby ensure that an overlap never happens.)