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

2021/3/26

adding Objects

aarav1514 aarav1514

2021/3/26

#
I can't seem to add objects. I have added a subclass of actor SpaceShip, I have made a world named AlienShooter, and I am trying to add the SpaceShip object in the AlienShooter. here's my code. World world = getWorld(); SpaceShip shooter = new SpaceShip(); world.addObject(shooter, 100, 100);
Risen Risen

2021/3/26

#
You can replace those 3 lines to this
World world = getWorld();
world.addObject(new SpaceShip(), 100, 100);
or
getWorld().addObject(new SpaceShip(), 100, 100);
danpost danpost

2021/3/26

#
Try just:
addObject(new SpaceShip(), 100, 100);
You need to login to post a reply.