Actor > Number

Actor > Number#

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

A number actor shows a Number.

You have to set the size of the actor with self.size() manually so that the complete text can be seen.

Parameters:
  • position – Top-Left position of Number.

  • number – The initial number

  • font-size – The size of the font (default: 80)

Examples

Sets a new NumberActor to display the score.:

self.score = NumberActor(position = (0, 0) number=0)

Gets the number stored in the NumberActor:

number = self.score.get_number()

Sets the number stored in the NumberActor:

self.score.set_number(3)
add(value)[source]

add the sprite to groups

Sprite.add(*groups): return None

Any number of Group instances can be passed as arguments. The Sprite will be added to the Groups it is not already a member of.

get_number()
Return type:

int

Returns:

The current number

Examples

Gets the number stored in the NumberActor:

number = self.number_actor.get_number()
get_value()[source]
Return type:

int

Returns:

The current number

Examples

Gets the number stored in the NumberActor:

number = self.number_actor.get_number()
inc()[source]

Increases the number by one

set_number(number)

Sets the number

Parameters:

number – The number which should be displayed

Examples

Sets the number stored in the NumberActor:

self.number_actor.set_number(3)
set_value(number)[source]

Sets the number

Parameters:

number – The number which should be displayed

Examples

Sets the number stored in the NumberActor:

self.number_actor.set_number(3)
sub(value)[source]
update_text()[source]