[GREENFOOT-327] setWorld is broken when actors are carried over
When setWorld is used, everything works as expected if all actor objects are created new after creating the new world.
If an existing actor is transferred from the old world to the new, and not explicitly removed from the old world (but instead just added to the new), then things go wrong (sometimes?). The actor seems to do collision detection incorrectly, possibly against objects in the other world, even though the actor's 'world' field refers to the new world.
An example is attached. In the Pengu class, it contains two instances of
getWorld().removeObject(this);
to remove the object explicitly from the previous world before entering a new one. If the lines are executed everything is fine. If they are commented out, things go wrong.
The functionality should work even when not explicitly removed from the old world (that should be implied).
Issue metadata
- Issue type: Bug
- Priority: Low
- Fix versions: 2.1.1