Skip to content

Point and move towards the mouse

On every tick, point the sprite at the mouse and step forward β€” the sprite will chase the cursor around the stage.

whenGreenFlag(() => {
forever(() => {
pointTowards("mouse");
move(4);
});
});

The sprite turns to face the cursor and moves 4 steps toward it every frame. Increase the step count for a faster chase.

  • whenGreenFlag β€” run code when the green flag is clicked
  • forever β€” repeat a block of code indefinitely
  • pointTowards β€” point this sprite towards another sprite or the mouse
  • move β€” move forward by a number of steps
  • touching β€” check whether this sprite is touching a target, the mouse, or the edge
All recipes