Darsteller > Nummer

Darsteller > Nummer#

class miniworlds.actors.texts.number.Number(position: Tuple[float, float] | None = (0, 0), *args, **kwargs)[Quellcode]

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.

Parameter:
  • position (tuple) – Top-left position of the number actor.

  • number (int or float) – The initial number to display.

  • **kwargs – Additional arguments passed to the base class.

Example

Create and update a Number actor:

score = Number(position=(0, 0), number=0)
score.set_number(3)
print(score.get_number())
add(value)[Quellcode]

Add a value to the current number.

Parameter:

value (int or float) – The value to add.

Example:

number_actor.add(2)
get_number()

Get the current number.

Rückgabetyp:

int

Rückgabe:

The currently displayed number.

Rückgabetyp:

int

Example:

current = number_actor.get_number()
get_value()[Quellcode]

Get the current number.

Rückgabetyp:

int

Rückgabe:

The currently displayed number.

Rückgabetyp:

int

Example:

current = number_actor.get_number()
inc()[Quellcode]

Increase the number by 1.

Example:

number_actor.inc()
set_number(number)

Set the number to display.

Parameter:

number (int or float) – The number to set.

Example:

number_actor.set_number(3)
set_value(number)[Quellcode]

Set the number to display.

Parameter:

number (int or float) – The number to set.

Example:

number_actor.set_number(3)
sub(value)[Quellcode]

Subtract a value from the current number.

Parameter:

value (int or float) – The value to subtract.

Example:

number_actor.sub(5)
update_text()[Quellcode]

Update the visual text display to match the current number.

property value

Get or set the value of the number.

Rückgabe:

The current number.

Rückgabetyp:

int