Worlds

World

class serge.world.World(name)[source]

Bases: serge.common.Loggable, serge.serialize.Serializable, serge.common.EventAware

The main world object

The Engine will control main worlds. Each world has a number of Zones which contain Actors.

activateWorld()[source]

Called when the world is set as the current world

addActor(actor)[source]

Add an actor to the world

addZone(zone)[source]

Add a zone to the world

clearActors()[source]

Clear all the actors

clearActorsExceptTags(tags)[source]

Clear all actors except the ones with a tag in the list of tags

clearActorsWithTags(tags)[source]

Clear all actors with a tag in the list of tags

clearZones()[source]

Remove all the zones

deactivateWorld()[source]

Called when the world is deactivated

findActorByName(name)[source]

Return the actor with the give name in all zones

findActorsAt(x, y)[source]

Return the actors at a certain location

findActorsByTag(tag)[source]

Return all the actors in all zones based on the tag

getActors()[source]

Return all the actors

getEngine()[source]

Return the engine that we are owned by

hasActor(actor)[source]

Return True if this actor is in the world

init()[source]

Initialise from serialized state

processEvents(events)[source]

Handle the events

removeActor(actor)[source]

Remove the actor from the world

renderTo(renderer, interval)[source]

Render all of our actors in active zones

requestResortActors()[source]

Request that actors are resorted the next time we render

Call this if you have adjusted the rendering order of actors

rezoneActors()[source]

Move actors to the right zone based on their spatial location

scheduleActorRemoval(actor)[source]

Remove an actor at the end of the next update for the world

This method can be used to safely remove an actor from the world during the execution of the world update. It can sometimes be useful to do this when inside logic that is iterating over actors or inside the updateWorld event loop.

setEngine(engine)[source]

Set the engine that we are owned by

setGlobalForce(force)[source]

Set the global force for physics

setPhysicsStepsize(interval)[source]

Set the maximum step size for physics calculations

setZoom(zoom, x, y)[source]

Set the visual zoom on this world to zoom centered on x, y

sleepPhysicsForActors(actors)[source]

Tell the actors to go to sleep from a physics perspective

The actors will still be visible and will still be updated but they will not update their physics. Useful for optimising when an actor does not need to interact with the physics simulation for a while.

If an actor is unzoned then this will have no impact on them

updateWorld(interval)[source]

Update the objects in the world

wakePhysicsForActors(actors)[source]

Tell the actors to go to wake up from a physics perspective

Actors that were put to sleep (via sleepPhysicsForActors) will be woken up and take part in the physics simulation again.