Actors

Actor

Inheritance diagram of serge.actor.Actor
class serge.actor.Actor(tag, name='')[source]

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

Represents an actor

addedToWorld(world)[source]

Called when we are being added to the world

getAngle()[source]

Return the angle for the actor

getLayerName()[source]

Return our layer name

getNiceName()[source]

Return a nice name for this actor

getPhysical()[source]

Return the physical conditions

getRenderingOrder()[source]

Return the rendering order

getSpriteName()[source]

Return our sprite

init()[source]

Initialize from serialized form

move(x, y)[source]

Move by a certain amount

moveTo(x, y, no_sync=False, override_lock=False)[source]

Move the center of this actor to the given location, unless it is locked

You can override the lock by passing True to override lock.

removedFromWorld(world)[source]

Called when we are being removed from the world

renderTo(renderer, interval)[source]

Render this actor to the given renderer

setAngle(angle, sync_physical=False, override_lock=False)[source]

Set the angle for the visual

setLayerName(name)[source]

Set the layer that we render to

setPhysical(physical_conditions)[source]

Set the physical conditions

setRenderingOrder(order)[source]

Sets the order to render to the screen

You can set this to adjust when objects are rendered even within a layer. A lower number means that an actor will be rendered earlier - which means it will be behind others.

The default is 0, so you should set this to higher than 1000 if you want an actor to appear in front of other objects that have not been explicitly set.

setSpriteName(name)[source]

Set the sprite for this actor

setZoom(zoom)[source]

Zoom in on this actor

syncPhysics(spatial_only=False)[source]

Sync physics when the actors physical properties have been changed

updateActor(interval, world)[source]

Update the actor status

CompositeActor

Inheritance diagram of serge.actor.CompositeActor
class serge.actor.CompositeActor(*args, **kw)[source]

Bases: serge.actor.Actor

An actor that can have children, which are also actors

World operations on the parent, like adding and removing, will also apply to the children.

If the children are removed from the parent then they are also removed from the world.

addChild(actor)[source]

Add a child actor

addedToWorld(world)[source]

Called when we are being added to the world

getChildren()[source]

Return the list of children

getChildrenWithTag(tag)[source]

Return all the children with a certain tag

hasChild(actor)[source]

Return True if this actor already has this actor as a child

hasChildren()[source]

Return True if this actor has children

removeChild(actor, leave_in_world=False)[source]

Remove a child actor

removeChildren()[source]

Remove all the children

removedFromWorld(world)[source]

Called when we are being removed from the world

AbstractMountableActor

Inheritance diagram of serge.actor.AbstractMountableActor
class serge.actor.AbstractMountableActor(*args, **kw)[source]

Bases: serge.actor.CompositeActor

An base class for actors that you can mount other actors to

The other actors are located at a certain position relative to the position of this actor. You can use this actor to create clusters either visually or functionally.

mountActor()[source]

Mount the actor with the given offset

If original_rotation is True then the mount offset is taken as working against the original rotation (ie angle = 0) of the actor.

If rotate_with_actor is set to False then this actor will not rotate with the parent actor, it will just move.

unmountActor(actor)[source]

Unmount the actor

MountableActor

Inheritance diagram of serge.actor.MountableActor
class serge.actor.MountableActor(*args, **kw)[source]

Bases: serge.actor.AbstractMountableActor

An actor that you can mount other actors to

The other actors are located at a certain position relative to the position of this actor. You can use this actor to create clusters either visually or functionally.

moveTo(x, y, no_sync=False, override_lock=False)[source]

Move this actor

setAngle(angle, sync_physical=False, override_lock=False)[source]

Set the angle for the visual

PhysicallyMountableActor

Inheritance diagram of serge.actor.PhysicallyMountableActor
class serge.actor.PhysicallyMountableActor(tag, name='', mass=0.0, **kw)[source]

Bases: serge.actor.AbstractMountableActor

An physical actor that you can mount other physical actors to

The other actors are located at a certain position relative to the position of this actor. You can use this actor to create clusters either visually or functionally.

All actors must be under the control of the physics engine.

addedToWorld(world)[source]

The actor was added to the world

init()[source]

Initialise from serialized form

mountActor()[source]

Mount the actor with the given offset

moveTo(x, y, no_sync=False, override_lock=False)[source]

Move this actor

setAngle(angle, sync_physical=False, override_lock=False)[source]

Set the angle for the visual

unmountActor(actor)[source]

Unmount the actor

ActorCollection

Inheritance diagram of serge.actor.ActorCollection
class serge.actor.ActorCollection[source]

Bases: list

A list of actors

This class implements some useful methods which help to handle collections of actors.

findActorByName(name)[source]

Return then actor with the given name

findActorsByTag(tag)[source]

Return a collection of actors with the given tag

findActorsByTags(tags)[source]

Return a collection of actors with at least one of the tags

forEach()[source]

Returns an object suitable for mapping method calls to all the actors in the collection

Use this like,
collection.forEach().setAngle(12)
hasActor(actor)[source]

Return True if we have that actor

hasActorWithName(name)[source]

Return True if the collection contains an actor with the given name

hasActorWithTag(tag)[source]

Return True if the collection contains an actor with the given tag

numberOfActorsWithName(name)[source]

Return the number of actors with the given name

numberOfActorsWithTag(tag)[source]

Return the number of actors with the given tag