Stage::whenIReceive(message) Beispiele Syntax Java Scratch Parameter Rückgabe Stage::whenIReceive(message) Diese Methode wird aufgerufen, wenn ein Broadcast empfangen wird. Beispiele import org.openpatch.scratch.*; public class SpriteBroadcast { public SpriteBroadcast() { Stage myStage = new ReceiveStage(); myStage.add(new BroadcastSprite()); myStage.add(new ReceiveSprite()); while (myStage.getTimer().forMillis(3000)) {} myStage.exit(); } public static void main(String[] args) { new SpriteBroadcast(); } } class ReceiveStage extends Stage { public ReceiveStage() { super(600, 240); } public void whenIReceive(String message) { if (message.equals("change-custome")) { this.changeColor(50); } } } class BroadcastSprite extends Sprite { public BroadcastSprite() { this.addCostume("zeta", "assets/zeta_green_badge.png"); this.addCostume("gamma", "assets/gamma_purple_badge.png"); } public void whenClicked() { this.broadcast("change-custome"); this.nextCostume(); } } class ReceiveSprite extends Sprite { public ReceiveSprite() { this.addCostume("zeta", "assets/zeta_green_badge.png"); this.addCostume("gamma", "assets/gamma_purple_badge.png"); this.changeX(50); } @Override public void whenIReceive(String message) { if ("change-custome".equals(message)) { this.nextCostume(); this.say("Got it!"); } } } Auf GitHub anschauen Syntax Java void whenIReceive(message) Scratch when I receive [message v] Parameter Name Datentyp Beschreibung message String Die Nachricht des Broadcasts. Rückgabe void whenIReceive(message)