Sprite Lab Documentation

location of 
Category:Locations

Gets the location of a given sprite.

This block can be used to get the exact location of the center of a sprite, even when it moves around the screen.

Examples

Example 1

The first sprite is drawn at a random location, but the second sprite is always drawn at the same place.

Example 2

This block allows one sprite to move towards another, no matter where it is on the screen. Here is a simple tag game where you can press the spacebar to make the chaser follow the runner.

Syntax

locationOf

Parameters

NameTypeRequired?Description
sprite

The sprite or sprite group whose location is being called

Tips

  • The sprite’s location is determined by where the center of the sprite is.

Found a bug in the documentation? Let us know at support@code.org.