Zones

class serge.zone.Zone[source]

Bases: serge.geometry.Rectangle, serge.common.Loggable

A zone

A zone is part of a world. It is a container for objects and it controls whether objects will take part in world updates.

addActor(actor)[source]

Add an actor to the zone

clearActors()[source]

Remove all actors

findActorByName(name)[source]

Return the actor with the given name

findActorsByTag(tag)[source]

Return all the actors with a certain tag

findFirstActorByTag(tag)[source]

Return the first actor found with the given tag or raise an error

getActors()[source]

Return all the actors

hasActor(actor)[source]

Return True if the actor is in this zone

init()[source]

Initialise from serialized state

removeActor(actor)[source]

Remove an actor from the zone

setGlobalForce(force)[source]

Set the global force for physics

setPhysicsStepsize(interval)[source]

Set the maximum step size for physics calculations

sleepActor(actor)[source]

Tell the actor to go to sleep from a physics perspective

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

updatePhysics(interval)[source]

Perform a step of the physics engine

You do not normally need to call this method as it is called by the updateZone method. You may call this to advance the physics simulation along without affecting other game elements.

updateZone(interval, world)[source]

Update the objects in the zone

wakeActor(actor)[source]

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

An actor that was put to sleep (via sleepActor) will be woken up and take part in the physics simulation again.

wouldContain(actor)[source]

Return True if this zone would contain the actor as it is right now

The base Zone implementation uses spatial overlapping as the criteria but you can create custom zones that use other criteria to decide which actors should be in the zone.