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

2015/9/13

how do i spawn actors?

oscarreks oscarreks

2015/9/13

#
so I just started a small project. The drag, drop, and act interface is cool, but how do i spawn all the actors into my scenario by just pressing Act? I have a "hand" actor and a "reticule" actor, and II want them to appear in the world once I press act, without having to do the dragging thing. I've looked through the API and stuff, but no luck. any help?
Super_Hippo Super_Hippo

2015/9/13

#
Are you sure you want to press 'Act' to spawn the actors? Usually you spawn objects when you create the world. So your world constructor may look like this:
super(600, 400, 1); //maybe you changed it, but you have the 'super' call there

//Here, you can add objects using the 'addObject' method
addObject(new Hand(), 40, 60);
addObject(new Reticule(), 50, 20);
As an alternative, you can place all objects where you want them and press 'Save the world' (or similar). But this usually causes messy code if you use it a few times.
oscarreks oscarreks

2015/9/15

#
Oh, that makes sense. Thanks. I didn't realize the world could be used that way.
D-Hightower D-Hightower

2015/9/15

#
you can also just put them where you want then save the world
You need to login to post a reply.