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

2014/4/14

How to get one actor's position from other actor??

Rishav_Agarwal Rishav_Agarwal

2014/4/14

#
I want to get another actor's position from the current actor....How to do this by calling method?? PLZZZ......HELP!!!!
danpost danpost

2014/4/14

#
When is the one actor needing to know the position of the other? Is there any interaction between the two actors that triggers the need to know? Basically, why does the actor need this information (or for what purpose is the information needed)?
Rishav_Agarwal Rishav_Agarwal

2014/4/14

#
I am making a paddle-ball game....I want that in the beginning (when ball is not launched) the ball moves along with the paddle when the paddle is moved...
Rishav_Agarwal Rishav_Agarwal

2014/4/14

#
Please help!!!
danpost danpost

2014/4/14

#
The ball will have two states -- an unlaunched state and a launched state. In the one (unlaunched) it will move with the paddle; and in the other it will move around on its own. You will need a Boolean field to track the unlaunched/launched state of the ball. When it is not launched, the paddle should be directly below it; so, you can use 'int paddleX = getOneObjectsAtOffset(0, getImage().getHeight()/2+5, Paddle.class).getX();' to get the x-coordinate of the paddle and then move the ball using 'setLocation(paddleX, getY());' to keep it with the paddle. If the ball is launched, then it should move normally.
Rishav_Agarwal Rishav_Agarwal

2014/4/14

#
Thank you very much danpost!!!
You need to login to post a reply.