Alex Brenton

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.
Alex Brenton
  • Posts: 8

Mario

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");
}
User avatar
Mario

Mario
  • Posts: 3152

Alex Brenton

Yes, it worked. Thank you so much!

---
Alex Brenton
  • Posts: 8


Return to Runtimes