Stage::find()
Returns a list of all objects of a certain class, which are currently on the stage. It does not matter if they are visible or not.
Examples
import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
public class StageFind {
public StageFind() {
Stage myStage = new Stage(600, 240);
myStage.add(new CustomSprite());
myStage.add(new CustomSprite());
myStage.add(new Sprite());
myStage.display("Sprites: " + myStage.find(CustomSprite.class).size());
myStage.wait(2000);
myStage.exit();
}
class CustomSprite extends Sprite {}
public static void main(String[] args) {
new StageFind();
}
}
Syntax
Java
.find(class)
Scratch
Parameters
Name | Data Type | Description |
---|---|---|
class | Class | The class of objects you want to find. |
Return
List