urgent please how to check left, right, top and bottom
i have an rectangle as an actor and a jumping actor,
how do i detect whether the jumping actor has either touched the left, right, top or bottomof the rectangle..
thanks
how do i detect whether the jumping actor has either touched the left, right, top or bottomof the rectangle..
thanks
Comments
simply constrain to attributes to the rectangles x and y positions
then compare the positions between the actor and the rectangle when they collide and you can tell where it has collided. For example:
if the actors self position x is less then the self position x of the rectangle when it collides, you know it collided on the left of the rectangle. If the actors self position x is greater then the self position x of the rectangle when it collides, you know it collided on the right of the rectangle
if the actors self position y is greater then the self position y of the rectangle when it collides, you know it collided on the top of the rectangle. and if the actors self position y is less then the self position y of the rectangle when it collides, you know it collided on the bottom of the rectangle
cheers
simply constrain to attributes to the rectangles x and y positions
then compare the positions between the actor and the rectangle when they collide and you can tell where it has collided. For example:
if the actors self position x is less then the self position x of the rectangle when it collides, you know it collided on the left of the rectangle. If the actors self position x is greater then the self position x of the rectangle when it collides, you know it collided on the right of the rectangle
if the actors self position y is greater then the self position y of the rectangle when it collides, you know it collided on the top of the rectangle. and if the actors self position y is less then the self position y of the rectangle when it collides, you know it collided on the bottom of the rectangle
cheers
simply constrain to attributes to the rectangles x and y positions
then compare the positions between the actor and the rectangle when they collide and you can tell where it has collided. For example:
if the actors self position x is less then the self position x of the rectangle when it collides, you know it collided on the left of the rectangle. If the actors self position x is greater then the self position x of the rectangle when it collides, you know it collided on the right of the rectangle
if the actors self position y is greater then the self position y of the rectangle when it collides, you know it collided on the top of the rectangle. and if the actors self position y is less then the self position y of the rectangle when it collides, you know it collided on the bottom of the rectangle
cheers
simply constrain to attributes to the rectangles x and y positions
then compare the positions between the actor and the rectangle when they collide and you can tell where it has collided. For example:
if the actors self position x is less then the self position x of the rectangle when it collides, you know it collided on the left of the rectangle. If the actors self position x is greater then the self position x of the rectangle when it collides, you know it collided on the right of the rectangle
if the actors self position y is greater then the self position y of the rectangle when it collides, you know it collided on the top of the rectangle. and if the actors self position y is less then the self position y of the rectangle when it collides, you know it collided on the bottom of the rectangle
cheers
so i constrained the rectangles x and y positions,
in my actor i put in a rule for when it collides with the rectangle
if actors self.position.x < game.pos.x note:(game.pos.x = rectangles self.position.x)then
display text = left
end if
this works when you hit the left of the rectangle but when my actor jumps on the top left of the rectangle its still alerts left, rather than saying top...
please help thanks