I use typescript runtime compiled to JS Canvas 2d.
I will try check collision with bounding box. All works correctly but when I try first use "SkeletonBounds.prototype.update()" function I get sixteen (16) times this error:
17:07:33.483 TypeError: polygon is undefined SkeletonBounds.prototype.update()spine-core.js
I check collision one time per frame, so after 16 frames I got info about collision. I have a little delay after clicks mouse button to action.
When
if (polygon.length != boundingBox.worldVerticesLength) {
polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);
}
I change to
//if (polygon.length != boundingBox.worldVerticesLength) {
polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);
//}
All works correctly and I dont have a delay between my click and collision checking (delay time is 16 frames).
Maybe I make something wrong and some more initializations are required? Now I do it "skeletonBounds = new spine.SkeletonBounds();" after load skeleton.
Any example how to use properly collision detection with JS runtime?