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

2020/1/15

adding only 1 actor

TakedaYeet TakedaYeet

2020/1/15

#
hello, im making a simple game, when the player interacts with a character they are supposed to talk by adding a text box this is my code if (this.getWorld().getClass() == plains2.class) { if (getX() >= 489) { if (getX() <= 495) { if (getY() >= 195) { if (getY() <= 210) { World world=getWorld(); world.addObject(new MspeechS2_1(), 261, 300); } } } } } } this ends up creating a large amount of actors instead of only one. please help!
danpost danpost

2020/1/15

#
Try first line of:
if ( (getWorld() instanceof plains2) && getWorld().getObjects(MspeechS2_1.class).isEmpty() ) {
TakedaYeet TakedaYeet

2020/1/15

#
wow! that worked perfectly, thank you very much!
You need to login to post a reply.