本文整理汇总了C++中Bone::_getNodeToParentTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::_getNodeToParentTransform方法的具体用法?C++ Bone::_getNodeToParentTransform怎么用?C++ Bone::_getNodeToParentTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::_getNodeToParentTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: die
void DrillMan::die(b2Vec2 vec)
{
if (footBody != NULL) {
gameWorld->DestroyBody(footBody);
footBody = NULL;
}
setB2bodyPosition();
if (!dead) {
for (auto o : deadSpriteArray) {
if (armature->getScaleX() < 0) {
o->setScaleX(-o->getScaleX());
}
}
armature->setVisible(false);
b2Filter filter;
filter.categoryBits = DEAD_ZOMBIE;
filter.maskBits = UPPER_GROUND | BASE_GROUND;
const Map<std::string, Bone*>& dic = armature->getBoneDic();
for(auto& element : dic)
{
Bone *bone = element.second;
Skin *skin = (Skin*)element.second->getDisplayRenderNode();
string name = element.first;
int torqRandWay = rand()%2;
float torgRand = (rand()%100)/100.0*2.7+2.7;
if (torqRandWay == 0)
{
torgRand = -torgRand;
}
if (skin) {
b2Body *body = skin->body;
body->GetFixtureList()->SetFixtureType(f_bodydead); //dead bodies fixturetype
body->GetFixtureList()->SetFilterData(filter);
body->SetType(b2_dynamicBody);
printf("name: %s\n", name.c_str());
if (name.compare("tou") == 0) {
float rNum = (rand()%100)/100*1.1+1.0;
vec = b2Vec2(vec.x*rNum, vec.y);
}
body->ApplyLinearImpulse(vec, body->GetWorldCenter(), true);
body->ApplyAngularImpulse(torgRand, true);
Bone *parentBone = bone->getParentBone();
if (parentBone) {
Skin *parentSkin = (Skin*)parentBone->getDisplayRenderNode();
b2Body *parentBody = parentSkin->body;
b2RevoluteJointDef jdef;
//CCAffineTransform tran = bone->nodeToParentTransform();
Mat4 tran = bone->_getNodeToParentTransform();
Point p = Point(tran.m[12], tran.m[13]);
// Point p = skin->getWorldPosition();
//printf("p x = %f y = %f\n", p.x, p.y);
jdef.Initialize(parentBody, body, b2Vec2(p.x/PTM_RATIO, p.y/PTM_RATIO));
jdef.lowerAngle = -0.35f * b2_pi;
jdef.upperAngle = 0.35f * b2_pi;
jdef.enableLimit = true;
gameWorld->CreateJoint(&jdef);
}
}
}
//update(0);
dead = true;
setBodySprites();
for (auto o : deadSpriteArray) {
o->setVisible(true);
}
}
}
示例2: headDropDie
void NormalEnemy::headDropDie()
{
if (footBody != NULL) {
gameWorld->DestroyBody(footBody);
footBody = NULL;
}
setB2bodyPosition();
if (!dead) {
for (auto o : deadSpriteArray) {
if (armature->getScaleX() < 0) {
o->setScaleX(-o->getScaleX());
}
}
armature->setVisible(false);
b2Filter filter;
filter.categoryBits = DEAD_ZOMBIE;
filter.maskBits = UPPER_GROUND | BASE_GROUND;
const Map<std::string, Bone*>& dic = armature->getBoneDic();
for(auto& element : dic)
{
//Ref *o = dickeyarr->objectAtIndex(i);
// CCString *key = dynamic_cast<CCString*>(o);
Bone *bone = element.second;
Skin *skin = (Skin*)element.second->getDisplayRenderNode();
string name = element.first;
if (skin) {
b2Body *body = skin->body;
body->GetFixtureList()->SetFixtureType(f_bodydead);
body->GetFixtureList()->SetFilterData(filter);
body->SetType(b2_dynamicBody);
Bone *parentBone = bone->getParentBone();
string selfName = bone->getName();
string parentName;
if (parentBone) {
parentName = parentBone->getName();
}
if (parentBone && selfName.compare("headbone") != 0 && parentName.compare("headbone") != 0) {
Skin *parentSkin = (Skin*)parentBone->getDisplayRenderNode();
b2Body *parentBody = parentSkin->body;
b2RevoluteJointDef jdef;
Mat4 tran = bone->_getNodeToParentTransform();
Point p = Point(tran.m[12], tran.m[13]);
// Point p = skin->getWorldPosition();
//printf("p x = %f y = %f\n", p.x, p.y);
jdef.Initialize(parentBody, body, b2Vec2(p.x/PTM_RATIO, p.y/PTM_RATIO));
jdef.lowerAngle = -0.35f * b2_pi;
jdef.upperAngle = 0.35f * b2_pi;
jdef.enableLimit = true;
gameWorld->CreateJoint(&jdef);
}
}
}
// update(0);
setBodySprites();
dead = true;
for (auto o : deadSpriteArray) {
o->setVisible(true);
}
}
}