Hi:
使用Cocos studio 的动画编辑器,为动画添加碰撞区后导入游戏中。
但是游戏中, 绘制的碰撞区和动画图片位置不重合,真实的碰撞发生
点是按照碰撞区发生的。在discuss.cocos2d-x.org 中也搜索到
相关问题但是没有解决 http://discuss.cocos2d-x.org/t/how-to-use-physics-with-armature/15146
寻求高人解决这个问题。
以下是导入代码:
string name = “BeautyAnimation”;
Armature* beautyTest = Armature::create(name);
beautyTest->setPosition( 100 , 200 );
this->addChild(beautyTest,20);
b2BodyDef bodyDef;
bodyDef.type =b2_dynamicBody;
bodyDef.position = b2Vec2(beautyTest->getPosition().x / PTM_RATIO, beautyTest->getPosition().y / PTM_RATIO);
b2Body* body = m_world->CreateBody(&bodyDef);
beautyTest->setBody(body);
b2Filter filter;
filter.categoryBits = 1;
filter.maskBits = 1;
for (b2Fixture* shapes = beautyTest->getShapeList(); shapes; shapes = shapes->GetNext())
{
shapes->SetSensor(false);
shapes->SetDensity(0.5f / CC_CONTENT_SCALE_FACTOR());
shapes->SetRestitution(0.0f);
shapes->SetFriction(0.2f);
shapes->SetFilterData(filter);
}
以下是问题截图




