spine web player怎么允许用户拖动,放大动画
How does spine web player allow users to drag and zoom in on animations
spine web player怎么允许用户拖动,放大动画
How does spine web player allow users to drag and zoom in on animations
To allow users to drag and zoom in on animations in the Spine Web Player, you would need to implement custom code. The Spine Web Player itself does not provide built-in functionality for zooming or dragging animations. However, you can access the player and manipulate the camera or viewport settings through JavaScript. For dragging, you can make use of the player's ability to drag skeleton bones. For zooming, you would need to write custom code to adjust the camera or viewport scale. You can refer to the Spine Web Player's source code and understand how the camera works to implement these features.
phtcloud 我使用了python作为后端遍历了当前目录下所有json文件相关代码如
I used python as the backend to traverse all the json file-related code in the current directory, such as
`html_content_parts.append(f"""
<div id="player-container" class="player-container"></div>
<script src="/spine-player.js"></script>
<script>
const mouseWorldPosition = new spine.Vector3();
const targetModifiedPosition = new spine.Vector3();
let targetBone;
const player = new spine.SpinePlayer("player-container", {{
skeleton: "{selected_file_encoded}",
atlas: "{selected_file_encoded.replace('.json', '.atlas')}",
backgroundColor: "#00000000",
animation: "",
skin: "01_Skin",
showControls: true,
premultipliedAlpha: true
}});
</script>
""")`
As Spinebot said, the web player does not have built-in drag and zoom. What language you use on the backend does not matter, as implementing that functionality is done on the frontend with JavaScript.
I'm afraid the code you posted is either incomplete or got cut off. Depending on your use case, it might be simpler to use a different web runtime, like spine-pixie or spine-phaser, which are more geared towards games where dragging and pinch zoom are common interactions provided by the game engine.