Category:Sprites

Gets a specific sprite from an event.

Using the costume block, you can program with events to check for interactions involving any sprite with the same costume(s). This block allows you to program an action to only affect the sprite that triggered the event. In an event that involves two sprites, “this” refers to first sprite in the event, and “other” refers to the second sprite. Using this block makes it possible to apply actions to specific sprites after an event without having to use a sprite name or affect the whole costume group.

Examples

Example 1

Using “this” lets an action apply to just one sprite in a costume group without creating a name for every sprite. In this example, any sun that is clicked will disappear when clicked without affecting the others.

Example 2

“Other” only works if more than one sprite is involved. When two sprites touch, “this” and “other” can be used to make a different action occur for each sprite. Press 'up' and 'down' arrows to have the middle sprite eat the pizza.

Parameters

NameDescription
this/other Two options: this or other. Default is this.

Tips

  • “This” sprite can be used in any action that is triggered by an event with a sprite. However, “other” only works with two sprites. Like the names suggest, there is “this” main sprite and a secondary “other” sprite.

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