Table of Contents

Function Definition: setrotationstyle(rotation_style = "left-right")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
rotation_stylestringThe rotation style of the sprite."left-right", "all around", or "don't rotate""left-right"

Description

The function changes the rotation style of the sprite in-project. There are three options for this function:

  1. all around: All around means the sprite can face any of the 360 degrees. It is the default.
  2. left-right: Left-right means sprite can only face left or right, and any other directions are rounded. The sprite will also be horizontally flipped when facing left in the left-right style.
  3. don’t rotate: Don’t rotate means that the sprite always faces as in 90°.

It takes only one input.

Example

The example demonstrates the wall bouncing of the sprite, rotation style, and costume change in Python.

Code

sprite = Sprite('Tobi')
import time

sprite.setrotationstyle('left-right')

while True:
  sprite.move(5)
  sprite.bounceonedge()
  sprite.switchcostume("Tobi walking 1")
  time.sleep(0.1)
  
  sprite.move(5)
  sprite.bounceonedge()
  sprite.switchcostume("Tobi walking 2")
  time.sleep(0.1)

Output

Read More
All articles loaded
No more articles to load