• 日本語
  • starlingでslotとhittest

Related Discussions
...

SkeletonAnimationの中にあるslotの位置を特定してimageとのhittestを可能にしたいのです。

https://github.com/harayoki/SpineTest1/blob/Straling2_Spine3_4_demo/src/harayoki/spine/starling/SpineHittestUtil.as

似たような物は探したのですがうまく作動しませんでした。 😢

なにか方法はないでしょうか?


(チェックすべき)すべてのスロットにPointを入れPointAttachmentを使って対応しました。
チェックするスロットが多くなるとぐだぐだになると思いますが… :wonder:

キャラクターがクリックされているかどうかチェックしようとしていますか?

Spineには、Spineエディタで定義できるBoundingBox Attachment があります。
そして、ヒットチェックするコードで SkeletonBounds を使用することができます。

badlogicやNateがサンプルコードを手助けできるかどうかを見てみましょう。

Original:
Are you trying to check if the character is being clicked on?

Spine has BoundingBox Attachments you can define in Spine editor.
And then you can use SkeletonBounds in code to hit-check.

Let's see if badlogic or Nate can help with the example code.

Pharan氏によると、BoundingBox添付ファイルの使用が最適な選択です。 ヒットテストポイントがスケルトンの座標系にある場合(ここをクリックしてください))、次のコードを使用してバウンディングボックスをチェックすることができます:

var bounds: SkeletonBounds = new SkeletonBounds();
bounds.update(skeletonSprite.skeleton, true);
var firstHitBoundingBox = bounds.containsPoint(localX, localY);

あなたが RegionAttachmentとMeshAttachmentに対してテストできるように独自のロールを作りたいなら、Polygon クラス 。 添付ファイルのために計算したワールド頂点配列に vertices フィールドをセットし、containsPoint()intersectsSegment() のようなメソッドを使います。

Original:
As Pharan said, using BoundingBox Attachments is likely the best choice. Provided you have your hit test point in the skeleton's coordinate system (as you do here), the following code can be used to check against the bounding boxes:

var bounds: SkeletonBounds = new SkeletonBounds();
bounds.update(skeletonSprite.skeleton, true);
var firstHitBoundingBox = bounds.containsPoint(localX, localY);

If you want to roll your own so you can test against RegionAttachment and MeshAttachment, you could use the Polygon class. Set it's vertices field to the world vertices array you calculate for an attachment, then use any of the methods like containsPoint() or intersectsSegment().

返答ありがとうございます!
サンプルコードを参考にBoundingを色々試してみたいと思います!! :clap: