I don’t understand why the argument sprite
works in the function below. Why do you have to pass that to retrieve the key that triggered the event, and where is the data coming from?
var character = this.add.sprite(x, z, 'character');
character.play('character_create');
character.on('animationcomplete', function (sprite)
{
if (sprite.key === 'character_create')
{
character.play('character_repeat');
}
}, this);
I see that it works great for doing a comparison on what the current key, but I don’t know at all why it works after reading the documentation. Why wouldn’t character.key work?