mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +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>
|
<li>
|
||||||
<a href="/spine-pixi/example/mouse-following.html">Mouse following</a>
|
<a href="/spine-pixi/example/mouse-following.html">Mouse following</a>
|
||||||
</li>
|
</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/physics.html">Physics</a></li>
|
||||||
<li><a href="/spine-pixi/example/physics2.html">Physics II</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>
|
<li><a href="/spine-pixi/example/physics3.html">Physics III</a></li>
|
||||||
|
|||||||
@ -30,13 +30,12 @@
|
|||||||
app.stage
|
app.stage
|
||||||
.on('pointerup', endDrag)
|
.on('pointerup', endDrag)
|
||||||
.on('pointerupoutside', endDrag)
|
.on('pointerupoutside', endDrag)
|
||||||
.on('pointermove', (e) => {
|
.on('pointermove', ({ x, y }) => {
|
||||||
if (dragObject) {
|
if (dragObject) {
|
||||||
let mousePosition = new spine.Vector2(e.data.global.x, e.data.global.y);
|
dragObject.x += x - lastX;
|
||||||
dragObject.x += mousePosition.x - lastX;
|
dragObject.y += y - lastY;
|
||||||
dragObject.y += mousePosition.y - lastY;
|
lastX = x;
|
||||||
lastX = mousePosition.x;
|
lastY = y;
|
||||||
lastY = mousePosition.y;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,16 +85,15 @@
|
|||||||
app.stage.addChild(control);
|
app.stage.addChild(control);
|
||||||
|
|
||||||
control.interactive = "static";
|
control.interactive = "static";
|
||||||
control.on('pointerdown', (e) => {
|
control.on('pointerdown', ({ x, y }) => {
|
||||||
dragObject = control;
|
dragObject = control;
|
||||||
let mousePosition = new spine.Vector2(e.data.global.x, e.data.global.y);
|
lastX = x;
|
||||||
lastX = mousePosition.x;
|
lastY = y;
|
||||||
lastY = mousePosition.y;
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
PIXI.Ticker.shared.add(() => {
|
PIXI.Ticker.shared.add(() => {
|
||||||
let point = { x: 0, y: 0 };
|
const point = { x: 0, y: 0 };
|
||||||
for (let { bone, control } of controlBones) {
|
for (let { bone, control } of controlBones) {
|
||||||
point.x = control.x;
|
point.x = control.x;
|
||||||
point.y = control.y;
|
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. */
|
/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
|
||||||
pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
|
pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
|
||||||
let transform = this.worldTransform.clone();
|
let transform = this.worldTransform.clone().invert();
|
||||||
transform = transform.invert();
|
|
||||||
let a = transform.a,
|
let a = transform.a,
|
||||||
b = transform.b,
|
b = transform.b,
|
||||||
c = transform.c,
|
c = transform.c,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user