• Runtimes
  • Spine Web Player - custom button to change animation?

Related Discussions
...

Hello. I integrated Spine Web Player to my website according to this topic: http://ru.esotericsoftware.com/spine-player#JSON-and-atlas-URL
Now I need to create custom button to change animation. Please help my to do this. I tried:

<div class="my_button" onclick="change_animation()"></div>

<script>
function change_animation() {
    SpinePlayer.setAnimation('jump');
}
</script>

But I'm geting "SpinePlayer is not defined" error.

When you create the player via JavaScript, just assign it to a variable, then reference it in your click listener. Something like:

var player = new spine.SpinePlayer("player", ...);
function changeAnimation() {
   player.setAnimation("jump");
}
3ヶ月 後

Yes, it worked. Thank you so much!