Actor Location Tracking
spaz
Member Posts: 6
I want to do something (start a timer & animate) an actor when the actor is dragged to a location that is within a certain area. I can handle the timer and animation, but I need help with the location tracking. The location is a rectangular area that is fixed (does not change during the game). I came across this article - http://gamesalad.com/wiki/how_tos:gsc_track_if_actor_is_over_another, which I may be able to adapt, but there may be a better way so I wanted to check with you guys first. Thanks in advance for pointing me in the right direction.
Comments
Let's take a rectangle that has the <- side at 0, the -> 100, the up side at 100 and the down side at 0.
Now, if player.x is > of 0, and < of 100, then it is between the rectangle vertical sides.
if player.y is > of 0 and < of 100, then it is between the rectangle vertical sides.
So, if player.x is > of 0, and < of 100
if player.y is > of 0, and < of 100
then player is inside the rectangle.
If you want to make that it doesn't just check the x and y position (the center of the player object) but if the whole player object is inside the rectangle, make it a square.
if player.x is > of 0 + player.width, and < of 100 - player.width
if player.y is > of 0 + player.height, and < of 100 - player.height
then player is inside the rectangle.
Hope this helps