Table of Contents

Function Definition: goto(moveto = "_random_")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
movetostringThe code where the sprite need to be moved."_random_""_random_"

Description

The function sets its sprite’s X and Y position to that of the mouse-pointer or another sprite — in other words, it moves the sprite to a random position, the mouse-pointer, or another sprite.

Example

The example demonstrates how to implement mouse tracking in Python.

Code

sprite = Sprite('Tobi')

while True:
  if (sprite.iskeypressed("space")):
    sprite.goto("_mouse_")

Output

Read More
All articles loaded
No more articles to load