Sprite::setWhenIReceive()
Sets the handler for when a message is received. This allows you to define custom behavior. This is useful when you do not want to extend the sprite class and want to use the sprite class directly.
For example:
Sprite sprite = new Sprite();
sprite.setWhenIReceive((message) -> {
System.out.println("Received message: " + message);
});
Syntax
Java
.setWhenIReceive(whenIReceive)
Parameters
| Name | Data Type | Description |
|---|---|---|
| whenIReceive | WhenIReceiveHandler | An IReceiveHandler that takes a Sprite and a message |
Return
void
