class documentation

An extension of a Scratchy Sprite to display text dynamically. The text is rendered to a surface and stored as the one and only costume. This is a simple-to-use sprite on top of pygame.font.

Method __init__ If x,y is given, the sprite is positioned from center like normal. If topleft is given, the left edge remains constant when text changes. If topright is given, the right edge remains constant. The 'justification' (left, right, center) applies to text that has or wraps to multiple lines, and is the alignment within the sprite...
Method set_text Undocumented
Method _render_text No summary
Instance Variable _bgcolor Undocumented
Instance Variable _color Undocumented
Instance Variable _costumes Undocumented
Instance Variable _font Undocumented
Instance Variable _justification Undocumented
Instance Variable _maxWidth Undocumented
Instance Variable _size Undocumented
Instance Variable _topleft Undocumented
Instance Variable _topright Undocumented

Inherited from Sprite:

Async Method ask_and_wait @return answer as a string
Method broadcast Undocumented
Method change_size_by Undocumented
Method change_x_by Undocumented
Method change_y_by Undocumented
Method clone Make a shallow clone of this sprite. Important: The cloned sprite is not automatically on the same stage as the original; specify the 'stage' parameter to add the sprite to the stage. Costumes are not reloaded but can be manipulated independently...
Method destroy Undocumented
Method direction_to Bonus: gives the direction in degrees from this Sprite to the given thing. @param what Can be any of * Sprite another sprite - distance center to center * An (x,y) position tuple @return a direction in the range [-180,180), where 0 means the other object is directly above this one.
Method distance_to @param what Can be any of * Sprite another sprite - distance center to center * An (x,y) position tuple
Method forever Undocumented
Method glide_to Glide to the given x, y in the background without waiting. @return The task object which can be waited on for completion.
Async Method glide_to_and_wait Undocumented
Method glide_to_position Similar to glide_to but with single position argument
Async Method glide_to_position_and_wait Similar to glide_to_and_wait but with single position argument
Method go_backward_layers Move this sprite backward the number of layers you specify.
Method go_forward_layers Move this sprite forward the number of layers you specify.
Method go_rect Go to a position determined by the keywords accepted by pygame.Rect.
Method go_to Undocumented
Method go_to_back_layer Move this sprite behind of all other sprites.
Method go_to_front_layer Move this sprite on top of all other sprites.
Method go_to_position Go to the (x,y) postion, given as a tuple. @see scratchypy.random_position() @see scratchypy.mouse_pointer()
Method hide Undocumented
Method if_on_edge_bounce TODO: add padding
Method if_on_edge_snap Undocumented
Method message Sends a message to this sprite. (Bonus extension of Scratch). If there is no message event handler (registered with when_i_receive()), for the given messageName, then the message is ignored. @param messageName The message name, as a string @param argDictionary Optional extra parameters to give as part of the message FIXME: this should post to a queue, not run handler directly?...
Method move Move steps (pixel lengths) in the direction of the current rotation. @param steps Distance to travel. May be a fraction. FIXME for left-right mode
Method next_costume Undocumented
Method point_in_direction Set the *direction* to the given degrees. The sprite will point that direction regardless of its current direction.
Method point_towards Undocumented
Method run Run the async function in the background until completion or until this sprite is destroyed.
Method say Will stay indefinitely or until another say/think. Say None or blank to clear bubble.
Async Method say_and_wait Undocumented
Method set_debug Undocumented
Method set_draggable Undocumented
Method set_rotation_style Use one of the enumerated values.
Method set_size_to Undocumented
Method set_x_to Undocumented
Method set_y_to Undocumented
Method show Undocumented
Method switch_costume_to TODO: support switch by name (file name?) @param number The index (number) of the costume to select. Remember, in Python, counting starts at 0, 1, 2, ...
Method think Will stay indefinitely or until another say/think. Say None or blank to clear bubble.
Async Method think_and_wait Undocumented
Method touching @param what Can be any of * Sprite another sprite - will compare against masks * pygame.sprite.Group [ADVANCED] * An (x,y) position tuple * A pygame.color.Color (but can't be an RGB tuple) * Sprite...
Method touching_color Undocumented
Method touching_edge Undocumented
Method turn Change the direction by the amouny of degrees given in degrees. A positive number is clockwise 🔃. A negative number is counter-clockwise 🔄.
Method update Called once per frame to do updates.
Method when_clicked When this sprite is clicked, call the given handler. The handler is of the form: ``` def myClickHandler(sprite, clickPosition): pass ``` Where 'sprite' is this sprite object where the click was delivered, and clickPosition is the tuple (x,y) position of the click relative to the sprite.
Method when_i_receive Register a callback to call when this sprite receives a message with the given messageName. The handler is of the form: ``` def myMessageHandler(sprite, argDictionary): pass ``` Where 'sprite' is this sprite object where the click was delivered, and the argDictionary is whatever kind of extra information goes with the message, as a dictionary of key, value pairs.
Method when_key_pressed Undocumented
Constant EDGE Undocumented
Property costume_name Undocumented
Property costume_number Undocumented
Property direction The "direction" in Scratch is the angle the character is facing. By default, the cat faces right, 90 degrees - that is equivalent to not being rotated (0 degrees). Direction is in the range -179.99.. to +180 inclusive.
Property name @return the name of the sprite set in the constructor
Property position Undocumented
Property rect Undocumented
Property size @return the size (scaling percent) as a number, where 100% is full size.
Property visible @return True if visible, or False if hide() has been called.
Property x_position sprite.x is an alias for this. @return the x coordinate of the center of this sprite.
Property y_position sprite.y is an alias for this. @return the y coordinate of the center of this sprite.
Method _applyImage Apply scales and transforms to original image, then set sprite vars
Method _loadCostumes Undocumented
Method _make_bubble Undocumented
Method _on_key_down Undocumented
Method _on_mouse_motion Undocumented
Method _render Undocumented
Instance Variable _backgroundTasks Undocumented
Instance Variable _costumeIndex Undocumented
Instance Variable _debug Undocumented
Instance Variable _draggable Undocumented
Instance Variable _image Undocumented
Instance Variable _keyHandlers Undocumented
Instance Variable _mask Undocumented
Instance Variable _messageHandlers Undocumented
Instance Variable _name Undocumented
Instance Variable _on_click Undocumented
Instance Variable _on_tick Undocumented
Instance Variable _rect Undocumented
Instance Variable _rotation Undocumented
Instance Variable _rotationStyle Undocumented
Instance Variable _sayThinkImages Undocumented
Instance Variable _scale Undocumented
Instance Variable _stage Undocumented
Instance Variable _visible Undocumented
Instance Variable _x Undocumented
Instance Variable _y Undocumented
def __init__(self, text, color=color.BLACK, font=None, size=50, x=0, y=0, topleft=None, topright=None, justification='left', name=None, maxWidth=600, bgcolor=None, stage=None):

If x,y is given, the sprite is positioned from center like normal. If topleft is given, the left edge remains constant when text changes. If topright is given, the right edge remains constant. The 'justification' (left, right, center) applies to text that has or wraps to multiple lines, and is the alignment within the sprite. If a custom font is given, then 'size' is ignored.

def set_text(self, text):

Undocumented

def _render_text(self, text):
_bgcolor =

Undocumented

_color =

Undocumented

_costumes =

Undocumented

_font =

Undocumented

_justification =

Undocumented

_maxWidth =

Undocumented

_size =

Undocumented

_topleft =

Undocumented

_topright =

Undocumented