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

2019/4/4

reference for X and Y position

duster2801 duster2801

2019/4/4

#
guys i want to make a refference from one actor to anoughter to get the X and Y position of number one. That way i can make the second actor add or subtract one pixel from the position to get it closer to the first actor.
danpost danpost

2019/4/4

#
To get a reference to your "NumberOne" object, you can do this:
if ( ! getWorld().getObjects(NumberOne.class).isEmpty() )
{
    Actor n1 = (Actor)getWorld().getObjects(NumberOne.class).get(0);
    ...
If the number one actor is always in the world, you can skip the line 1 checking and just use line 3 to get the reference.
duster2801 duster2801

2019/4/4

#
Thank you very much my friend, i now realise the mistake i made thank you!
danpost danpost

2019/4/4

#
duster2801 wrote...
Thank you very much my friend, i now realise the mistake i made thank you!
You should probably share so others who come across this discussion do not make the same mistake.
You need to login to post a reply.