Event data is a object with at least one property event what is the event name. Some event data have more properties, see parameter in the list above.
{
event: 'movefigure',
fig: 32,
pos: {x: 1, y: 1},
newpos: {x: 3, y: 2}
}
game.on('movefigure', myAnimation);
function myAnimation (data) {
var tween = new TWEEN.Tween( ...
}
Call function on( eventName, callBackFunction ) to subscribe a event. You also can subscribe all kinds of events when eventName is 'all':
game.on('all', myCallBack);
There is an internal event listener, the 'logger'. It will print all events to console.
Use game.enableLogger(true) for activation.
event move_begin fig: bush (2), pos: [0,0]
event setfigure fig: bush (2), pos: [0,0], score: 20
event animate_begin
event animate_end
event nextfigure fig: grass (1)
event move_end fig: bush (2), pos: [0,0], score: 20
Use an array of event names to log special events only.
var loggedGameEvents = ["move_begin","move_end","move_fail","swapreserve","newgame","gameover","undo"];
game.enableLogger( loggedGameEvents );