Actor > Widgets#
Label#
- class miniworlds.actors.widgets.label.Label(position: Tuple[float, float] | None = (0, 0), *args, **kwargs)[source]#
Public Data Attributes:
Inherited from
SingleWidget
padding_left
padding_right
padding_top
padding_bottom
position
The position of the actor as Position(x, y)
topleft
center
row_height
text_align
Defines how text is aligned.
text
The text which is displayed on the widget.
Inherited from
BaseWidget
padding_left
padding_right
padding_top
padding_bottom
position
The position of the actor as Position(x, y)
topleft
center
row_height
Inherited from
ParentActor
visible
You can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layer
Defines the layer on which the actor is drawn if several actors overlap.
Inherited from
Actor
collision_type specifies how collisions should be checked:
A actor with the property
is_blockable
cannot move through actors with the propertyis_blocking
.A actor with the property
is_blockable
cannot move through actors with the propertyis_blocking
.Defines the layer on which the actor is drawn if several actors overlap.
Actor position in last frame
Returns number of costumes of actor, 0 if actor has no costume
When a actor is mirrored, it is mirrored across the y-axis.
Gets the costume of actor
Gets the costume manager
Directions are handled exactly as in the Scratch programming language, see: Scratch Wiki
Gets the direction as value in unit circle (0° right, 90° top, 180° left...)
If actor is dirty, it will be repainted.
Size of the actor
The width of the actor in pixels.
The height of the actor in pixels.
The x-value of a actor
The y-value of a actor
x-value of actor topleft-position
x-value of actor topleft-position
x-value of actor center-position inside the current camera-screen
x-value of actor center-position
y-value of actor center-position
Defines if the costume of a actor should be rotatable.
Should actor react to events? You can turn this option off for additional performance boost.
The fill color of actor as rgba value, e.g. (255, 0, 0) for red.
The fill color of actor as rgba value, e.g. (255, 0, 0) for red.
Is actor filled with color?
border color of actor.
border color of actor.
The border-size of actor.
You can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
The surrounding Rectangle as pygame.Rect.
The image of the actor:
The position of the actor as Position(x, y)
is_display_initialized
actor_id
children
speed
ask
Inherited from
DirtySprite
visible
You can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layer
Layer property can only be set before the sprite is added to a group, after that it is read only and a sprite's layer in a group should be set via the group's change_layer() method.
Inherited from
Sprite
layer
Dynamic, read only property for protected _layer attribute.
Public Methods:
__init__
(text[, image])Inherited from
Button
__init__
([text, image])on_clicked_left
(mouse_pos)This event is called when the button is clicked -
Inherited from
SingleWidget
__init__
([position])resize
()cut_widget_text
()update_positions
()get_local_pos
(position)set_row_height
([value])set_border
([color, width])sets border of widget
set_position
(value)set_world
(new_world)get_widget_text
()set_image
(_img_source)sets image of widget
set_text
(text)Sets text of widget.
get_text
()Inherited from
BaseWidget
__init__
([position])new_costume
()resize
()update_positions
()get_local_pos
(position)set_row_height
(value)set_border
([color, width])sets border of widget
set_world
(new_world)set_position
(value)Inherited from
ParentActor
__init__
(position[, children])add_child
(actor)set_layer
(value)set_world
(new_world)reset_costumes
()before_remove
()Inherited from
Actor
__init__
([position])switch_origin
(value)create_on_world
(world)Creates a actor to a specific world
from_topleft
(topleft_position, *args, **kwargs)Creates a actor with center at center_position
from_center
(center_position, *args, **kwargs)Creates a actor with center at center_position
flip_x
()Flips the actor by 180° degrees.
add_costume
([source])Adds a new costume to actor.
add_costumes
(sources)Adds multiple costumes
remove_costume
([source])Removes a costume from actor
switch_costume
(source)Switches the costume of actor
set_costume
(costume)set_background_color
(color)Switches to the next costume of actor
turn_left
([degrees])Turns actor by degrees degrees left :rtype:
int
turn_right
([degrees])Turns actor by degrees degrees right
set_direction
(direction)Actor points in given direction.
point_towards_position
(destination)Actor points towards a given position
point_towards_actor
(other)Actor points towards another actor.
set_size
(value)scale_width
(value)scale_height
(value)move
([distance])Moves actor distance steps in current direction
move_vector
(vector)Moves actor in direction defined by the vector
move_up
([distance])move_down
([distance])move_left
([distance])move_right
([distance])move_back
(distance)Undo the last move.
move_towards
(target)move_in_direction
(direction[, distance])Moves actor distance steps into a direction or towards a position
move_to
(position)Moves actor distance to a specific world_posiition
remove
([kill])Removes this actor from world
bounce_from_border
(borders)The actor "bounces" from a border.
detect_all
([actors, direction, distance])Detects if actors are on actor position.
detect
(*args, **kwargs)Detects if actors are on actor position.
detect_borders
([distance])Detects borders :rtype:
List
Does the actor touch the left border?
Does the actor touch the right border?
Does the actor touch the lower border?
Does the actor touch the lower border?
detect_color
([color])Detects colors in world-background at actor center-position
detect_color_at
([direction, distance])Detects colors in world-background at actor-position
detect_actors_at
([direction, distance, actors])Detects a actor in given direction and distance.
detect_actor_at
([direction, distance, actors])detect_actors_in_front
([actors, distance])detect_actor_in_front
([actors, distance])detect_point
(position)Is the actor colliding with a specific (global) point?
detect_pixel
(position)Is the actor colliding with a pixel?
detect_rect
(rect)Is the actor colliding with a static rect?
Is the actor colliding with a static rect?
bounce_from_actor
(other)animate
([speed])animate_costume
(costume[, speed])animate_loop
([speed])Animates a costume with a looping animation
Stops current animation.
send_message
(message)Sends a message to world.
on_key_down
(key)on_key_down is called one time when a key is pressed down.
on_key_pressed
(key)on_key_pressed is called when while key is pressed.
on_key_up
(key)on_mouse_over
(position)on_mouse_over is called, when mouse is moved over actor :type position: :param position: The mouse position
on_mouse_leave
(position)on_mouse_over is called, when mouse is moved over actor :type position: :param position: The mouse position
on_mouse_left
(position)on_mouse_left is called when left mouse button was pressed.
on_mouse_right
(position)Method is called when right mouse button was pressed.
on_mouse_motion
(position)Method is called when mouse moves.
on_mouse_left_released
(position)Method is called when left mouse key is released.
on_mouse_right_released
(position)Method is called when right mouse key is released.
on_clicked_left
(position)The mouse is on top of a actor and mouse was clicked.
on_clicked_right
(position)The mouse is on top of a actor and mouse was clicked.
on_detecting_world is called, when actor is on the world
on_detecting_world is called, when actor is on the world
on_detecting_actor
(actor)on_detect_actor is called, when actor is detects a actor on same position
on_detecting_borders
(borders)on_detecting_border is called, when actor is near a border
fill
(value)Set fill color for borders and lines
hide
()Hides a actor (the actor will be invisible)
show
()Displays a actor ( an invisible actor will be visible)
register
(method[, force, name])This method is used for the @register decorator.
register_message
(*args, **kwargs)This method is used for the @register_message decorator.
register_sensor
(*args, **kwargs)This method is used for the @register_sensor decorator.
__str__
()Return str(self).
set_world
(new_world)set_position
(value)get_distance_to
(obj)Gets the distance to another actor or a position
Inherited from
DirtySprite
__init__
(*groups)__repr__
()Return repr(self).
Inherited from
Sprite
__init__
(*groups)add
(*groups)add the sprite to groups
remove
(*groups)remove the sprite from groups
add_internal
(group)For adding this sprite to a group internally.
remove_internal
(group)For removing this sprite from a group internally.
update
(*args, **kwargs)method to control sprite behavior
kill
()remove the Sprite from all Groups
groups
()list of Groups that contain this Sprite
alive
()does the sprite belong to any groups
__repr__
()Return repr(self).
Private Data Attributes:
Inherited from
Actor
_world
_sensor_manager
_position_manager
_costume_manager
_collision_type
_layer
_is_acting
Private Methods:
Inherited from
Actor
_validate_arguments
(position, *args, **kwargs)Inherited from
DirtySprite
_set_visible
(val)set the visible value (0 or 1) and makes the sprite dirty
_get_visible
()return the visible value of that sprite