【Bug反馈】
使用版本:1.5.0.1
问题描述:
运行环境:cocos2d-js-v3.0-rc0
骨骼无法旋转,armature.getBone(“rotation_node”).setRotation(degrees)后,骨骼角度是错的
联系方式:******
该问题的暂时解决方法:
对骨骼的旋转操作改为对骨骼的display做旋转,代码:
armature.getBone(“rotation_node”).getDisplayRenderNode().setRotation(degrees);
该操作在H5下可以正常旋转,在JSB下不行,需要修改 CCSkin代码:
CCSkin.cpp updateTransform函数修改如下:
void Skin::updateTransform()
{
// If it is not visible, or one of its ancestors is not visible, then do nothing:
if( !_visible)
{
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0, 0, 0);
}
else
{
//
// calculate the Quad based on the Affine Matrix
//
Mat4 transform = getNodeToParentTransform();
Size &size = _rect.size;
float x1 = _offsetPosition.x;
float y1 = _offsetPosition.y;
float x2 = x1 + size.width;
float y2 = y1 + size.height;
float x = transform.m;
float y = transform.m;
float cr = transform.m;
float sr = transform.m;
float cr2 = transform.m;
float sr2 = -transform.m;
float ax = x1 * cr - y1 * sr2 + x;
float ay = x1 * sr + y1 * cr2 + y;
float bx = x2 * cr - y1 * sr2 + x;
float by = x2 * sr + y1 * cr2 + y;
float cx = x2 * cr - y2 * sr2 + x;
float cy = x2 * sr + y2 * cr2 + y;
float dx = x1 * cr - y2 * sr2 + x;
float dy = x1 * sr + y2 * cr2 + y;
SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
}
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
if (_textureAtlas)
{
_textureAtlas->updateQuad(&_quad, _textureAtlas->getTotalQuads());
}
}