owo

Take the code as an example,How to play the specified animation when the mouse clicks the model in the web player?
<script <removed>
<link rel="stylesheet" <removed>

<div id="player-container" style="width: 100%; height: 100vh;"></div>

<script>
new spine.SpinePlayer("player-container", {
jsonUrl: "http://esotericsoftware.com/files/examples/4.0/spineboy/export/spineboy-pro.json",
atlasUrl: "http://esotericsoftware.com/files/examples/4.0/spineboy/export/spineboy.atlas"
});
</script>
owo
  • Posts: 3

Mario

Here's a simple example on Codepen that plays an animation when the player's div is clicked:
https://codepen.io/badlogicgames/pen/qBKRXKW
User avatar
Mario

Mario
  • Posts: 3277

owo

Thank you very much for your reply, very useful!
If a model has two PNG files of clothing textures, can the textures be switched when player's div clicked? If so how to achieve
owo
  • Posts: 3

Mario

Use the skins feature for that:
Skins - Spine User Guide

You can pack multiple outfits into a single texture atlas so you don't have to manually load/swap png files. Just set the skin:
player.skeleton.setSkinByName("name-of-the-skin");
User avatar
Mario

Mario
  • Posts: 3277


Return to Editor