- Edited
cocos2d-x render attachment/slot to texture/sprite
Could anybody help me. I need render spine2d attachment/slot to cocos2d-x texture or sprite? Or how i could read pixel ? My prime task test pixel in attachment/slot if it transperency or not.
You can find sample code here for rendering a skeleton to texture Rendering to Texture
I would strongly suggest to NOT do this every frame for collision detection, it will be too slow. Instead, add bounding boxes to your skeleton in the Spine editor, and use them for collision detection.
Thx for help. Could you give me code sample how i can get bounding box acess from spine runtimes? I am needed detecting from my program when i click inside or outside bounding box. Can spine runtimes has this fucntions or i only can take vertexes coordinates of bounding box ?
We do not yet have a function in SkeletonRenderer that let's you check if a point is inside a bounding box. However, doing that manually is pretty simple:
SkeletonAnimation* skel = ...
spSkeleton* skel->getSkeleton();
spSkeletonBounds* bounds = spSkeletonBounds_create();
spSkeletonBounds_update(bounds, skeleton, true);
spBoundingBoxAttachment* hitBounds = spSkeletonBounds_containsPoint(bounds, x, y); // the coordinates are given in the skeleton's/node's local coordinate system
if (hitBounds) {
... do something ...
}
spSkeletonBounds_dispose(bounds); // dispose the bounds when you no longer need them.
Thx i will try this.