Actor > Widgets#
Etikett#
- class miniworlds.actors.widgets.label.Label(position: Tuple[float, float] | None = (0, 0), *args, **kwargs)[Quellcode]#
Öffentliche Datenattribute:
Inherited from
Buttonfixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
SingleWidgetpadding_leftpadding_rightpadding_toppadding_bottompositionThe position of the actor as Position(x, y)
topleftcenterrow_heighttext_alignDefines how text is aligned.
textThe text which is displayed on the widget.
fixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
BaseWidgetpadding_leftpadding_rightpadding_toppadding_bottompositionThe position of the actor as Position(x, y)
topleftcenterrow_heightfixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
ParentActorvisibleYou can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layerDefines the layer on which the actor is drawn if several actors overlap.
childrenactor_countclass_imageactor_idspeedInherited from
Actorcollision_type gibt an, wie Kollisionen überprüft werden sollen:
A actor with the property
is_blockablecannot move through actors with the propertyis_blocking.A actor with the property
is_blockablecannot move through actors with the propertyis_blocking.Defines the layer on which the actor is drawn if several actors overlap.
Actor-Position im letzten Frame
Returns number of costumes of actor, 0 if actor has no costume
Wenn ein Actor gespiegelt wird, wird er entlang der y-Achse gespiegelt.
Gets the costume of the actor, if available.
Ruft den Kostümmanager ab
Directions are handled exactly as in the Scratch programming language, see: Scratch Wiki
Gibt die Richtung als Wert im Einheitskreis an (0° rechts, 90° oben, 180° links…)
Größe des Actors
Die Breite des Actors in Pixeln.
Die Höhe des Actors in Pixeln.
Der x-Wert eines Actors
Der y-Wert eines Actors
x-Wert der oberen linken Position des Actors
x-Wert der oberen linken Position des Actors
x-Wert der Actor-Mittelposition innerhalb des aktuellen Kamerabildschirms
x-Wert der Mittelpunktposition des Actors
y-Wert der Mittelpunktposition des Actors
Legt fest, ob das Kostüm eines Actors drehbar sein soll.
Should actor react to events? You can turn this option off for additional performance boost.
Die Füllfarbe des Actors als RGBA-Wert, z.B. (255, 0, 0) für Rot.
Die Füllfarbe des Actors als RGBA-Wert, z.B. (255, 0, 0) für Rot.
Ist der Actor mit Farbe gefüllt?
Randfarbe des Actors.
Randfarbe des Actors.
Die Randgröße des Actors.
You can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
Das Bild des Actors:
The position of the actor as Position(x, y)
actor_idspeedInherited from
ActorBasedirtyWenn der Actor schmutzig ist, wird er neu gezeichnet.
rectDas umgebende Rechteck als pygame.Rect.
position_managersensor_managercostume_managerInherited from
DirtySpritevisibleYou can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layerLayer 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
SpriteimagerectlayerDynamic, read only property for protected _layer attribute.
Öffentliche Methoden:
__init__(text[, image])Inherited from
Button__init__([text, image])on_clicked_left(mouse_pos)This event is called when the button is clicked -
act()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()Dreht den Actor um 180° Grad.
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:
intturn_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, direction])Moves actor distance steps in current direction
move_vector(vector)Moves actor in direction defined by the vector
move_back(distance)Machen Sie den letzten Zug rückgängig.
move_towards(target)move_in_direction(direction[, distance])Bewegt den Actor distance Schritte in eine direction oder zu einer Position
move_to(position)Bewegt den Actor distance zu einer bestimmten world_posiition
remove([kill])Entfernt diesen Actor aus der Welt
bounce_from_border(borders)“prallt” von einem Rand ab.
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
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 current ....
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 wird aufgerufen, wenn die Maus über den Actor bewegt wird :type position: :param position: Die Mausposition
on_mouse_leave(position)on_mouse_over wird aufgerufen, wenn die Maus über den Actor bewegt wird :type position: :param position: Die Mausposition
on_mouse_left_down(position)on_mouse_right_down(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_detecting_actor is called, when actor is detects a actor on same position
on_detecting_borders(borders)on_detecting_border wird aufgerufen, wenn sich der Actor in der Nähe einer Grenze befindet
fill(value)Füllfarbe für Ränder und Linien festlegen
hide()Verbirgt einen Actor (der Actor wird unsichtbar)
show()Zeigt einen Actor an (ein unsichtbarer Actor wird sichtbar)
register_sensor(*args, **kwargs)This method is used for the @register_sensor decorator.
set_world(new_world)set_position(value)get_distance_to(obj)Gets the distance to another actor or a position
Inherited from
ActorBaseregister(method[, force, name])This method is used for the @register decorator.
register_message(*args, **kwargs)Registriert eine Methode bei einem Objekt, um bestimmte
on_message-Ereignisse zu behandeln.__str__()Gib str(self) zurück.
get_costume_class()Inherited from
DirtySprite__init__(*groups)__repr__()Gib repr(self) zurück.
Inherited from
Sprite__init__(*groups)add(*groups)füge den Sprite zu Gruppen hinzu
remove(*groups)entferne den Sprite aus den Gruppen
add_internal(group)Um diesen Sprite intern zu einer Gruppe hinzuzufügen.
remove_internal(group)For removing this sprite from a group internally.
update(*args, **kwargs)method to control sprite behavior
kill()entferne den Sprite aus allen Gruppen
groups()Liste der Gruppen, die diesen Sprite enthalten
alive()gehört der Sprite zu irgendwelchen Gruppen
__repr__()Gib repr(self) zurück.
Private Datenattribute:
_abc_implInherited from
Button_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
SingleWidget_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
BaseWidget_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
ParentActor_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
Actor_abc_impl_world_sensor_manager_position_manager_costume_manager_collision_type_layer_is_acting__image__rectInherited from
ActorBase_abc_impl__image__rectPrivate Methoden:
Inherited from
Actor_validate_arguments(position, *args, **kwargs)Inherited from
ActorBase_is_actor_repainted()Inherited from
DirtySprite_set_visible(val)den sichtbaren Wert (0 oder 1) festlegen und den Sprite als verändert markieren
_get_visible()den sichtbaren Wert dieses Sprites zurückgeben