This site requires JavaScript, please enable it in your browser!
Greenfoot back
sanoy
sanoy wrote ...

2014/1/11

Actor detecting at certain position

sanoy sanoy

2014/1/11

#
I want the player in my scenario, to check for an actor at acertain position near him. eg. is ther an actor 2 pixel North or 5 pixel east is this posible
danpost danpost

2014/1/11

#
Use the 'getOneObjectAtOffset' method so that you can tell where to look for that actor.
Actor actor = getOneObjectAtOffset(0, -2, null);
will look 2 pixels north of the center of the player (2+getImage().getHeight()/2 will look to pixel above the top of the image of the player). Replace 'null' with the name of the class of the actor you wish to look for at that location.
You need to login to post a reply.