mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[ts][pixi] Add control bones example in example list
This commit is contained in:
parent
6c8d5e1615
commit
569adb1cd1
@ -36,6 +36,9 @@
|
||||
<li>
|
||||
<a href="/spine-pixi/example/mouse-following.html">Mouse following</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/spine-pixi/example/control-bones-example.html">Control bones example</a>
|
||||
</li>
|
||||
<li><a href="/spine-pixi/example/physics.html">Physics</a></li>
|
||||
<li><a href="/spine-pixi/example/physics2.html">Physics II</a></li>
|
||||
<li><a href="/spine-pixi/example/physics3.html">Physics III</a></li>
|
||||
|
||||
@ -30,13 +30,12 @@
|
||||
app.stage
|
||||
.on('pointerup', endDrag)
|
||||
.on('pointerupoutside', endDrag)
|
||||
.on('pointermove', (e) => {
|
||||
.on('pointermove', ({ x, y }) => {
|
||||
if (dragObject) {
|
||||
let mousePosition = new spine.Vector2(e.data.global.x, e.data.global.y);
|
||||
dragObject.x += mousePosition.x - lastX;
|
||||
dragObject.y += mousePosition.y - lastY;
|
||||
lastX = mousePosition.x;
|
||||
lastY = mousePosition.y;
|
||||
dragObject.x += x - lastX;
|
||||
dragObject.y += y - lastY;
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
});
|
||||
|
||||
@ -86,16 +85,15 @@
|
||||
app.stage.addChild(control);
|
||||
|
||||
control.interactive = "static";
|
||||
control.on('pointerdown', (e) => {
|
||||
control.on('pointerdown', ({ x, y }) => {
|
||||
dragObject = control;
|
||||
let mousePosition = new spine.Vector2(e.data.global.x, e.data.global.y);
|
||||
lastX = mousePosition.x;
|
||||
lastY = mousePosition.y;
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
})
|
||||
}
|
||||
|
||||
PIXI.Ticker.shared.add(() => {
|
||||
let point = { x: 0, y: 0 };
|
||||
const point = { x: 0, y: 0 };
|
||||
for (let { bone, control } of controlBones) {
|
||||
point.x = control.x;
|
||||
point.y = control.y;
|
||||
|
||||
@ -415,8 +415,7 @@ export class Spine extends Container {
|
||||
|
||||
/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
|
||||
pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
|
||||
let transform = this.worldTransform.clone();
|
||||
transform = transform.invert();
|
||||
let transform = this.worldTransform.clone().invert();
|
||||
let a = transform.a,
|
||||
b = transform.b,
|
||||
c = transform.c,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user