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

2013/5/27

Grabbing Location of Actor from another Actor

programmer274 programmer274

2013/5/27

#
Hey I was wondering how to achieve this. I have seen the other discussions but I still don't seem to be understanding the concept right. What I want to do is in an actor class Ball, get the y co ordinate of an Actor class called Zone and compare it to the Balls y coordinate.
danpost danpost

2013/5/27

#
If the ball is in a zone (intersecting a Zone object) then:
Actor zone = getOneIntersectingObject(Zone.class);
'zone' will either be 'null' (if the ball was not in a Zone object) or will contain the Zone object that the ball is in. From there you can use 'zone.getX()', 'zone.getY()', ... any Actor class method on the Zone object (provided that 'zone' is not 'null').
programmer274 programmer274

2013/5/28

#
This is not what I wanted. The Ball and Zone classes will not be intersecting. They will be floating alongside each other.
programmer274 programmer274

2013/5/28

#
wait never mind i think i can get it to work a different way. Thank You for the help
You need to login to post a reply.