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

2017/2/12

second world?

StarterCreator StarterCreator

2017/2/12

#
how do i choose on what world i spawn objects in,i know the getWorld().addObject"""""" but how do i choose on what world?
danpost danpost

2017/2/12

#
StarterCreator wrote...
how do i choose on what world i spawn objects in,i know the getWorld().addObject"""""" but how do i choose on what world?
Usually, each world will add objects into their own self (with code placed in their constructors or a 'prepare' method that is called by the constructor).
StarterCreator StarterCreator

2017/2/12

#
so wait,are the worlds combined?
danpost danpost

2017/2/12

#
StarterCreator wrote...
so wait,are the worlds combined?
Worlds are separate entities. You can have multiple worlds of the same type; but, they are each individual worlds. Maybe I am not understanding your question. Can you be more specific as to what your concern is? maybe give an example.
StarterCreator StarterCreator

2017/2/12

#
so do worlds stack up?how do u choose on what world will u be in if they are not stacked?
danpost danpost

2017/2/12

#
If you are using 'getWorld().addObject(...)', then the actor being added into a world will go in the same world that the current in-world actor is in -- the world returned by 'getWorld'.
Nosson1459 Nosson1459

2017/2/12

#
getWorld returns the world that the actor that the code is running from is currently in, I don't think you can get any other world, so the addObject will add it to the same world. (Not arguing with danpost just saying it in my own words)
You need to login to post a reply.