Event
Last updated
Last updated
Spine supports events which can be handled in code. Events are defined in Spine which can include parameters of different types such as ints, floats, and strings.
These events can be handled in code by subscribing to a SpineDrawableBatch's Event event, or through the FlatRedBall Editor.
To subscribe to an event in FRB Editor:
Create a SpineDrawableBatch object in your Entity
Drag+drop the SpineDrawableBatch into the Events folder
Change the name if desired, then press OK
The new event can be handled in the Events.cs file of your Entity. For example, if your Entity is named Soldier, the event is in Soldier.Event.cs.
The Event event is can be subscribed to just like any event in C#. To do so, simply use the +=
operator to add a handler to the Event, as shown in the following code snippet:
When a Spine event is raised it may have parameters which are passed. The parameter type can differ per event type, so the Event class that is passed to the handler contains the information.
You can decide the meaning of each paramter in your game. For example, you may decide to award points when a particular event occurs by reading the e.Int
value.