Add 'actorAdded' event on Scene
JohnSundell opened this issue · comments
John Sundell commented
In order to be able to observe whenever an actor was added to a scene, it would be awesome to have an event for it. That way really cool plugins could be written, like this:
class ColorAllActorsPlugin: Plugin {
func activate(for scene: Scene, in game: Game) {
scene.events.actorAdded.observe { scene, actor in
actor.backgroundColor = .red
}
}
}
The above plugin would add a red background color to all actors that are added to the scene that the plugin is attached to. Very useful to implement things like debug tools 👍
Things to do:
- Add a new event on
SceneEventCollection
for when an actor was added (see the other events for inspiration). - Trigger the event when a new actor is added to a scene.
Zubair Asgar commented