ScratchData LogoScratchData
Back to Bioruffo's profile

Following a clone - example

BIBioruffo•Created June 12, 2014
Following a clone - example
9
10
574 views
View on Scratch

Instructions

Just a small example to show how a sprite can follow one of several clones. Click on a red dot to have Scratch try to follow it.

Description

Each clone is assigned an ID at creation. It then forever stores its X position and Y position on two global lists. When clicked, a clone will store its ID in a global variable (clone to follow). Scratch will look for the ID stored in the clone to follow variable, and will retrieve the X and Y position of the clone from the list. It will then try to glide to that X,Y coordinate. Since I've implemented it with a 1-sec gliding, Scratch will only adjust to the new position of the clone once a second (when it reaches the gliding location). This is on purpose, just to leave things as simple as possible. But one can quickly substitute gliding for a more refined approach.

Project Details

Project ID23531440
CreatedJune 12, 2014
Last ModifiedJune 12, 2014
SharedJune 12, 2014
Visibilityvisible
CommentsAllowed