本文整理汇总了C++中PhysicsSprite::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsSprite::setVisible方法的具体用法?C++ PhysicsSprite::setVisible怎么用?C++ PhysicsSprite::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsSprite
的用法示例。
在下文中一共展示了PhysicsSprite::setVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setArmatureBody
void NormalEnemy::setArmatureBody()
{
//armature->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(NormalEnemy::animationEvent));
armature->getAnimation()->playWithIndex(0);
Vector<Node*> bonearr = armature->getChildren();
//printf("bonearr size = %zd\n",bonearr.size());
//Skin *dump = (Skin*)((Bone*)(bonearr.at(2)))->getDisplayRenderNode();
//batch = SpriteBatchNode::createWithTexture(dump->getTexture());
//gameScene->addChild(batch, armature->getZOrder());
// int z = bonearr->count();
for(int i = 0; i< bonearr.size();i++)
{
Bone *bone = (Bone*)bonearr.at(i);
string boneName = bone->getName();
Skin *skin = (Skin*)bone->getDisplayRenderNode();
if (skin !=NULL) {
skin->isphysicsObject = true;
skin->parentScale = armature->getScale();
Rect a = skin->getTextureRect();
Point partpos = skin->getWorldPosition();
float partrotation = skin->getWorldRotation();
float bodyrotation = partrotation*M_PI/180.0;
Size partSize = Size((a.getMaxX()-a.getMinX())/PTM_RATIO*armature->getScale(), (a.getMaxY()-a.getMinY())/PTM_RATIO*armature->getScale());
b2BodyDef bodyDef;
bodyDef.type = b2_staticBody;
bodyDef.position.Set(partpos.x/PTM_RATIO, partpos.y/PTM_RATIO);
b2Body *body_ = gameWorld->CreateBody(&bodyDef);
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(partSize.width/2.0, partSize.height/2.0);//These are mid points for our 1m box
b2CircleShape circleShape;
circleShape.m_radius = 0.45;
b2FixtureDef fixtureDef;
if (boneName.compare("headbone") == 0||boneName.compare("head")==0) {
fixtureDef.shape = &circleShape;
}
else if (boneName.compare("left_feet") == 0||boneName.compare("foot_right")==0)
{
circleShape.m_radius = 0.2;
fixtureDef.shape = &circleShape;
}
else {
fixtureDef.shape = &dynamicBox;
}
fixtureDef.density = 0.2f;
fixtureDef.restitution = 0.8;
fixtureDef.friction = 0.2f;
fixtureDef.filter.categoryBits = ZOMBIE;
// printf("bonename = %s\n", boneName.c_str());
if (boneName.compare("headbone") == 0||boneName.compare("head")==0) {
fixtureDef.fixturetype = f_zbody_body;
fixtureDef.filter.maskBits = BASE_GROUND | UPPER_GROUND | ARROW | BULLET;
}
else if (boneName.compare("bodybone") == 0||boneName.compare("body")==0) {
fixtureDef.fixturetype = f_zbody_body;
fixtureDef.filter.maskBits = BASE_GROUND | UPPER_GROUND | ARROW | BULLET;
}
else if (boneName.compare("leglbone") == 0 || boneName.compare("right_leg") == 0|| boneName.compare("right_foreleg")|| boneName.compare("foreleg_rbone") ||boneName.compare("left_leg")==0||boneName.compare("left_foreleg")==0) {
fixtureDef.fixturetype = f_zbody_body;
fixtureDef.filter.maskBits = BASE_GROUND | UPPER_GROUND | ARROW | BULLET;
}
else {
fixtureDef.fixturetype = f_zbody_body;
fixtureDef.filter.maskBits = BASE_GROUND | UPPER_GROUND;
}
body_->CreateFixture(&fixtureDef);
body_->SetUserData(this);
body_->SetTransform(b2Vec2(partpos.x/PTM_RATIO, partpos.y/PTM_RATIO), bodyrotation);
body_->SetAngularDamping(1.2);
skin->body = body_;
PhysicsSprite *dumpSprite = (PhysicsSprite*)PhysicsSprite::createWithTexture(skin->getTexture(), skin->getTextureRect());
dumpSprite->setPosition(skin->getWorldPosition());
dumpSprite->setScale(armature->getScale());
dumpSprite->setVisible(false);
dumpSprite->body = body_;
// printf("zorder = %i\n", bone->getZOrder());
// dumpSprite->setZOrder(bone->getZOrder()+3);
gameScene->addChild(dumpSprite,bone->getZOrder()+20);
//deadSpriteArray->addObject((Ref*)dumpSprite);
//.........这里部分代码省略.........