Table of Contents

switchcostume()

Function Definition: switchcostume(costume_name = "Tobi Jump")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
costume_namestringThe name of the target costume.String"Tobi Jump"

Description

The function changes its sprite’s costume to a specified one.

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
The example demonstrates the costume change in PictoBlox.

Code

sprite = Sprite('Tobi')

sprite.gotoxy(0, 0)
sprite.setsize(200)
sprite.switchcostume("Tobi")

while True:
  sprite.say(sprite.costume("name"), 1)
  sprite.nextcostume()

Output

Read More
All articles loaded
No more articles to load