Spine:修订间差异
来自卡厄思梦境WIKI
小无编辑摘要 |
无编辑摘要 |
||
| 第2行: | 第2行: | ||
<div id="spine-widget-<!--{$id|default:'player'}-->" style="width:<!--{$width|default:'640'}-->px; height:<!--{$height|default:'480'}-->px; background:<!--{$bg|default:'#ffffff'}-->;"></div> | <div id="spine-widget-<!--{$id|default:'player'}-->" style="width:<!--{$width|default:'640'}-->px; height:<!--{$height|default:'480'}-->px; background:<!--{$bg|default:'#ffffff'}-->;"></div> | ||
<link rel="stylesheet" href="https://esotericsoftware.com/files/spine-player/3.8/spine-player.css"> | <link rel="stylesheet" href="https://esotericsoftware.com/files/spine-player/3.8/spine-player.css"> | ||
<script> | <script> | ||
(function() { | (function() { | ||
var widgetId = "spine-widget-<!--{$id|default:'player'}-->"; | |||
var config = { | |||
jsonUrl: "<!--{$json}-->", | jsonUrl: "<!--{$json}-->", | ||
atlasUrl: "<!--{$atlas}-->", | atlasUrl: "<!--{$atlas}-->", | ||
| 第22行: | 第22行: | ||
showControls: true, | showControls: true, | ||
scale: parseFloat("<!--{$scale|default:'1'}-->") | scale: parseFloat("<!--{$scale|default:'1'}-->") | ||
}); | }; | ||
function initSpinePlayer() { | |||
if (typeof spine !== 'undefined' && spine.SpinePlayer) { | |||
new spine.SpinePlayer(widgetId, config); | |||
} else { | |||
console.error('Spine Player library not loaded'); | |||
} | |||
} | |||
// 检查是否已加载 Spine 库 | |||
if (typeof spine !== 'undefined') { | |||
initSpinePlayer(); | |||
} else { | |||
// 动态加载 Spine Player 脚本 | |||
var script = document.createElement('script'); | |||
script.src = 'https://esotericsoftware.com/files/spine-player/3.8/spine-player.js'; | |||
script.onload = function() { | |||
initSpinePlayer(); | |||
}; | |||
script.onerror = function() { | |||
console.error('Failed to load Spine Player library'); | |||
}; | |||
document.head.appendChild(script); | |||
} | |||
})(); | })(); | ||
</script> | </script> | ||
</includeonly> | </includeonly> | ||