Get Information About Other Sprites/Stage
-
Prerequisite
Introduction
You can use the following sensing block to get information about another sprite or the stage:
The Target Dropdown
The second input allows you to select a target object, which can be another sprite in this project, or the stage.
For example, in this project, there are 3 sprites “Cody”, “Apple” and “Avery”. If we are adding this block in the “Cody” sprite, we will see the other 2 sprites listed in the dropdown together with “Stage”:
Note that the “Cody” sprite itself is not on this list. That’s because we can use other ways to get information about this sprite itself, such as its x and y positions.
The Property Dropdown
The first input allows you to choose a property you would like to know about, such as its position or costume information. Note that this list is different if you choose the stage as the target, because the stage can not move.
Demo
Suppose we want the Cody sprite to always stay below the Apple sprite. We can add some code in the Cody sprite to repeatedly move it to the same X position as the Apple sprite, but a slightly lower Y position:
If we move the Apple sprite, then Cody will follow aumatically: