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

2015/5/11

Actor not in world. An attempt was made to use the actor's location while it is not in the world.

IronMagus IronMagus

2015/5/11

#
Hi, im trying to make an enemy that throws objects up in the air, then when it reaches the top they are removed, then a new one is instanced using the hero character X position, but im getting the error that he isnt in the world, maybe im using the wrong command lines, idk, i hope someone can help. code:
azazeel azazeel

2015/5/11

#
part of code please :)
danpost danpost

2015/5/11

#
Instance the new one from the hero class. Use 'if (getWorld().getObjects(Tossed.class).isEmpty())' as the condition to throw a new Tossed object.
danpost danpost

2015/5/11

#
IronMagus wrote...
code:
BossShot bossshot = new BossShot();
int hx;
Hero hero = new Hero();
hx = hero.getX();
getWorld().addObject(bossshot, hx, 100);
bossshot.setRotation(bossshot.getRotation()+90);
bossshot.move(-50);
Line 3 creates a new Hero object and line 4 tries to get its x coordinate in a world; however, it has not been added into any world (you may have a Hero object in the world, but it is not the same Hero object referenced here).
You need to login to post a reply.