Actor > Costume#

A Costume is a child class of Appearance. Most methods and attributes are inherited from the Appearance base class.

API Reference#

class miniworlds.appearances.costume.Costume(*args, **kwargs)[source]#

Appearance for an actor.

A costume contains one or more images and defines how an actor looks. You can switch images in a costume to animate the actor.

Parameters:
  • actor – Optional actor to attach the costume to.

  • source – Optional image path, surface, color tuple, or list of image sources.

Examples

actor.add_costume("images/player.png")

costume = Costume()
costume.add_image("images/walk1.png")
actor.add_costume(costume)

costume = Costume(actor, "images/player.png")
after_init()[source]#

Apply actor and world defaults after construction.

animation_length#
bind_to_actor(actor)[source]#
Return type:

None

classmethod create_managed(actor)[source]#
draw_images#
draw_shapes#
font_manager#
get_manager()[source]#

Return the owning costume manager of the actor.

get_rect()[source]#

Return a frame-cached local rect for the rendered costume image.

id#
image_manager: image_manager.ImageManager#
property info_overlay#

Whether to draw a debug overlay around the actor.

Examples

actor.costume.info_overlay = True
Type:

bool

initialized#
last_image#
loop#
origin_changed()[source]#

Mark rendering as dirty after an origin change.

parent#

the parent of a costume is the associated actor.

resized()[source]#

Mark scaling-dependent rendering as dirty.

rotated()[source]#

Mark rotation-dependent rendering as dirty after actor rotation.

set_dirty(value='all', status=1)[source]#

Set dirty flags and keep actor rect/mask caches in sync.

set_image(source)[source]#

Select the active costume image.

Return type:

bool

Parameters:

source – Image index, appearance, or color tuple.

Returns:

True if the image exists.

Examples

costume.set_image(0)
surface_loaded#
transformations_manager#
visibility_changed()[source]#

Mark full rendering as dirty after visibility updates.

property world: World#

Owning world of this costume.