Actor > Number#
- class miniworlds.actors.texts.number.Number(position: Tuple[float, float] | None = (0, 0), *args, **kwargs)[source]
A number actor that displays a numeric value (integer or float).
You must manually set the size of the actor with self.size() to ensure the text fits the screen.
- Parameters:
Example
Create and update a Number actor:
score = Number(position=(0, 0), number=0) score.set_number(3) print(score.get_number())
- add(value)[source]
Add a value to the current number.
Example:
number_actor.add(2)
- get_number()
Get the current number.
Example:
current = number_actor.get_number()
- get_value()[source]
Get the current number.
Example:
current = number_actor.get_number()
- inc()[source]
Increase the number by 1.
Example:
number_actor.inc()
- set_number(number)
Set the number to display.
Example:
number_actor.set_number(3)
- set_value(number)[source]
Set the number to display.
Example:
number_actor.set_number(3)
- sub(value)[source]
Subtract a value from the current number.
Example:
number_actor.sub(5)
- update_text()[source]
Update the visual text display to match the current number.
- property value
Get or set the value of the number.
- Returns:
The current number.
- Return type: