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

2021/6/14

How can name a certain object?

Turbo_Thorsten Turbo_Thorsten

2021/6/14

#
For example I want to only do something with border1, a object of my Border class. How can I target only border1 (in my case with isTouching("border1").
Gbasire Gbasire

2021/6/14

#
You can do this : in a world, for example MyWorld.class :
Border border1 = new Border();
addObject(border1, 100, 100);
and in an actor, for example Player.class :
Border border1= ((MyWorld)getWorld()).border1;
if(intersects(border1))
{
    //do something
}
Turbo_Thorsten Turbo_Thorsten

2021/6/14

#
Gbasire wrote...
You can do this : in a world, for example MyWorld.class :
Border border1 = new Border();
addObject(border1, 100, 100);
and in an actor, for example Player.class :
Border border1= ((MyWorld)getWorld()).border1;
if(intersects(border1))
{
    //do something
}
Thank you!
You need to login to post a reply.