Skip to content

Commit a3cda6e

Browse files
committed
Add is-inside-bone-radius action.
1 parent 00cc386 commit a3cda6e

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

spine-ts/spine-construct3/src/aces.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@
6969
}
7070
]
7171
},
72+
{
73+
"id": "is-inside-bone-radius",
74+
"scriptName": "IsInsideBoneRadius",
75+
"isTrigger": false,
76+
"params": [
77+
{
78+
"id": "x",
79+
"type": "number"
80+
},
81+
{
82+
"id": "y",
83+
"type": "number"
84+
},
85+
{
86+
"id": "bone-name",
87+
"type": "string"
88+
},
89+
{
90+
"id": "radius",
91+
"type": "number",
92+
"initial-value": 10
93+
}
94+
]
95+
},
7296
{
7397
"id": "is-animation-playing",
7498
"scriptName": "IsAnimationPlaying",

spine-ts/spine-construct3/src/c3runtime/conditions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds =
5757
IsInsideSlot (this: SpineC3Instance, x: number, y: number, slotName: string) {
5858
return this.isInsideSlot(x, y, slotName);
5959
},
60+
IsInsideBoneRadius (this: SpineC3Instance, x: number, y: number, boneName: string, radius: number) {
61+
return this.isInsideBone(x, y, boneName, radius);
62+
},
6063
IsAnimationPlaying (this: SpineC3Instance, animationName: string, trackIndex: number) {
6164
return this.isAnimationPlaying(animationName, trackIndex);
6265
},

spine-ts/spine-construct3/src/c3runtime/instance.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
364364
return this.isPointInPolygon(vertices, hullLength, coords.x, coords.y);
365365
}
366366

367+
public isInsideBone (x: number, y: number, boneName: string, radius: number) {
368+
const bone = this.getBone(boneName);
369+
if (!bone || !bone.active) return false;
370+
371+
const bonePos = this.matrix.boneToGame(bone);
372+
return this.inRadius(x, y, bonePos.x, bonePos.y, radius);
373+
}
374+
367375
public isAnimationPlaying (animationName: string, trackIndex: number) {
368376
if (!this.state) return false;
369377

spine-ts/spine-construct3/src/lang/en-US.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,29 @@
157157
}
158158
}
159159
},
160+
"is-inside-bone-radius": {
161+
"list-name": "Is point inside bone radius",
162+
"display-text": "Is point ({0}, {1}) within {3} pixels of bone {2}",
163+
"description": "Check if a point in world coordinates is within a specified radius of a bone's position",
164+
"params": {
165+
"x": {
166+
"name": "X",
167+
"desc": "X world coordinate"
168+
},
169+
"y": {
170+
"name": "Y",
171+
"desc": "Y world coordinate"
172+
},
173+
"bone-name": {
174+
"name": "Bone name",
175+
"desc": "Name of the bone to check"
176+
},
177+
"radius": {
178+
"name": "Radius",
179+
"desc": "Radius in pixels around the bone position"
180+
}
181+
}
182+
},
160183
"is-animation-playing": {
161184
"list-name": "Is animation playing",
162185
"display-text": "Is animation {0} playing on track {1}",

spine-ts/spine-construct3/src/lang/zh-CN.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,29 @@
157157
}
158158
}
159159
},
160+
"is-inside-bone-radius": {
161+
"list-name": "点是否在骨骼半径内",
162+
"display-text": "点({0}, {1})是否在骨骼{2}的{3}像素范围内",
163+
"description": "检查世界坐标中的点是否在骨骼位置的指定半径范围内",
164+
"params": {
165+
"x": {
166+
"name": "X",
167+
"desc": "X世界坐标"
168+
},
169+
"y": {
170+
"name": "Y",
171+
"desc": "Y世界坐标"
172+
},
173+
"bone-name": {
174+
"name": "骨骼名称",
175+
"desc": "要检查的骨骼名称"
176+
},
177+
"radius": {
178+
"name": "半径",
179+
"desc": "骨骼位置周围的半径(像素)"
180+
}
181+
}
182+
},
160183
"is-animation-playing": {
161184
"list-name": "动画是否正在播放",
162185
"display-text": "动画{0}是否在轨道{1}上播放",

0 commit comments

Comments
 (0)