本文整理汇总了C++中PhysicsBody::setCategoryBitmask方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsBody::setCategoryBitmask方法的具体用法?C++ PhysicsBody::setCategoryBitmask怎么用?C++ PhysicsBody::setCategoryBitmask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsBody
的用法示例。
在下文中一共展示了PhysicsBody::setCategoryBitmask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addToParent
void Tree::addToParent(Node* parent)
{
parent -> addChild( mLeavesSprite);
mLeavesSprite->setTag(1);
PhysicsBody* mLeavesBody = PhysicsBody::createCircle(mLeavesSize.width / 4, PHYSICSBODY_MATERIAL_DEFAULT);
mLeavesBody->setContactTestBitmask(1);
mLeavesBody->setCollisionBitmask(0);
mLeavesBody->setCategoryBitmask(1);
mLeavesNode -> setPhysicsBody( mLeavesBody);
parent->addChild(mLeavesNode);
mLeavesNode->setPosition(mLeavesPosition);
parent -> addChild( mBodySprite);
mBodySprite->setTag(1);
PhysicsBody* mBodyBody = PhysicsBody::createBox(mBodySize, PHYSICSBODY_MATERIAL_DEFAULT);
mBodyBody->setContactTestBitmask(1);
mBodyBody->setCollisionBitmask(0);
mBodyBody->setCategoryBitmask(1);
mBodyNode -> setPhysicsBody( mBodyBody);
parent->addChild(mBodyNode);
mBodyNode->setPosition(mPosition);
parent -> addChild( mRootSprite);
mLeavesSprite->setAnchorPoint(Vec2(0.5, -0.8));
mBodySprite -> setAnchorPoint(Vec2(0.5, 0));
mBodySprite -> setPosition(Vec2(mBodyPosition.x, mBodyPosition.y - mBodySprite->getContentSize().height / 2));
mLeavesSprite -> setPosition(mBodySprite->getPosition());
Rotation();
}
示例2: addPhysics
void Person::addPhysics()
{
auto size = (this->getBoundingBox()).size;
log("%lf %lf", size.width, size.height);
auto material = PhysicsMaterial(100.0f, 0.01f, 1.0f);
if(_type == TYPE::HERO) size.width /= 2;
PhysicsBody *body = PhysicsBody::createBox(Size(size.width,size.height),material);
// body->addShape(PhysicsShapeBox::create(Size(size.width,size.height),material));
body->setCategoryBitmask(_type);
if(_type == TYPE::MONSTER)
{
body->setCollisionBitmask(TYPE::MONSTER | TYPE::BRICK | TYPE::GROUND |
TYPE::TANGH | TYPE::BULLET | TYPE::BOSS | TYPE::PLANK);
body->setContactTestBitmask(TYPE::MONSTER | TYPE::HERO | TYPE::BRICK |
TYPE::TANGH | TYPE::BULLET | TYPE::BOSS);
}
else if(_type == TYPE::HERO)
{
body->setCollisionBitmask( TYPE::HERO | TYPE::GROUND | TYPE::TANGH | TYPE::PLANK);
body->setContactTestBitmask(TYPE::MONSTER | TYPE::HERO | TYPE::GROUND |
TYPE::TANGH | TYPE::BULLET | TYPE::TRAP | TYPE::BOSS |
TYPE::BULLETENEMY | TYPE::PLANK | TYPE::BUFF);
}
else if(_type == TYPE::BOSS)
{
body->setCollisionBitmask( TYPE::HERO | TYPE::GROUND | TYPE::BOSS | PLANK);
body->setContactTestBitmask( TYPE::HERO | TYPE::GROUND | TYPE::BOSS);
}
body->setDynamic(true);
body->setLinearDamping(0.0f);
body->setRotationEnable(false);
body->setGravityEnable(true);
this->setPhysicsBody(body);
}
示例3: joinToWorld
void Monster::joinToWorld(Node* parent)
{
Sprite* sp = Sprite::createWithSpriteFrameName(m_sModelPath.asString().c_str());
/* 创建刚体 */
PhysicsBody* body = PhysicsBody::createBox(sp->getContentSize());
body->setCategoryBitmask(1); // 0001
body->setCollisionBitmask(1); // 0001
body->setContactTestBitmask(1); // 0001
/* 精灵居中 */
sp->setPosition(Point(sp->getContentSize().width * 0.5f, sp->getContentSize().height * 0.5f));
/* 精灵作为Monster的表现,添加到Monster身上 */
this->addChild(sp);
/* 设置怪物Tag类型 */
this->setTag(ObjectTag_Monster);
/* 精灵作为Monster的表现,Monster本身没有大小,所以要设置一下大小 */
this->setContentSize(sp->getContentSize());
/* 刚体添加到Monster本身,而不是精灵身上 */
this->setPhysicsBody(body);
/* 设置坐标 */
this->setPosition(Point(getiPosX(), getiPosY()));
/* Monster加入到物理世界 */
parent->addChild(this);
}
示例4: init
bool guaiwu_js::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
auto root_layer = CSLoader::createNode("LayerUI/Other/guaiwu.csb");
addChild(root_layer);
auto rooaby = root_layer->getChildByName<Node*>("FileNode_1")->getChildByName<Sprite*>("anim_guaiwu_zo0001_2");
PhysicsBody* phybody = PhysicsBody::createBox(Size(rooaby->getContentSize().width-8, rooaby->getContentSize().height-20));
phybody->setTag(400001);
phybody->setMass(3000);
phybody->setRotationEnable(false);
phybody->setCategoryBitmask(0x01);
phybody->setCollisionBitmask(0x02);
phybody->setContactTestBitmask(0x01);
phybody->setDynamic(true);
rooaby->setPhysicsBody(phybody);
guaiwu = CSLoader::createTimeline("Node/animation/guaiwujs.csb");
guaiwu->gotoFrameAndPlay(0,35, true);
root_layer->runAction(guaiwu);
scheduleUpdate();
//添加碰撞事件
auto collisionlistener = EventListenerPhysicsContact::create();
collisionlistener->onContactBegin =CC_CALLBACK_1(guaiwu_js::onCollisionBegin, this);
collisionlistener->onContactSeparate = CC_CALLBACK_1(guaiwu_js::onContactSeparate,this);
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(collisionlistener, this);
return true;
}
示例5: initBody
void SpeedUpProtect::initBody()
{
auto s = getContentSize();
Vec2 vec[7] =
{
Vec2(0,0),
Vec2(s.width * 0.1, s.height * 0.4),
Vec2(s.width * 0.26, s.height * 0.72),
Vec2(s.width * 0.5, s.height),
Vec2(s.width * 0.74, s.height * 0.72),
Vec2(s.width * 0.9, s.height * 0.4),
Vec2(s.width,0),
};
PhysicsBody* body = PhysicsBody::createPolygon(vec, 7, PHYSICSBODY_MATERIAL_DEFAULT, Vec2(-s.width*0.5,-s.height*0.5));
body->setGravityEnable(false);
body->setRotationEnable(false);
body->setDynamic(false);
body->setMass(10000000);
body->setCategoryBitmask(SELF_SCOPE_CATEGORYBITMASK);
body->setCollisionBitmask(SELF_SCOPE_COLLISIONBITMASK);
body->setContactTestBitmask(SELF_SCOPE_CONTACTTESTBITMASK);
setPhysicsBody(body);
setInvincible(true);
m_ContactPro.hurts = -Ene_Plane_Hp_max - 10;
}
示例6: initPhyscsObject
void ShowLayer::initPhyscsObject(Rect* m)
{
for (int i = 0; i < 26; i++)
{
Sprite* sp = Sprite::create();
auto maskLayer = LayerColor::create(Color4B(0, 0, 255, 200));
maskLayer->setContentSize(m[i].size);
maskLayer->setAnchorPoint(Vec2(0, 0));
sp->addChild(maskLayer, 15);
PhysicsBody* playerBody = PhysicsBody::createBox(m[i].size, PHYSICSBODY_MATERIAL_DEFAULT);
playerBody->setDynamic(false);
//设置质量
playerBody->getShape(0)->setMass(100);
//设置物体是否受重力系数影响
playerBody->setGravityEnable(false);
playerBody->setCategoryBitmask(3);
playerBody->setContactTestBitmask(3);
playerBody->setCollisionBitmask(3);
sp->setContentSize(m[i].size);
sp->setPosition(Vec2(m[i].getMidX(), m[i].getMidY()));
sp->setAnchorPoint(Vec2(0.0, 0.0));
sp->setPhysicsBody(playerBody);
this->addChild(sp);
}
}
示例7: reload
void PFMPlayer::reload()
{
if(_preset == NULL)
return;
for(int i=0;i<_preset->components.size();i++)
{
PFMComponent* component = _preset->components[i];
if(component->componentClass == "Sprite")
{
PFMSpriteComponent* spriteComponent = dynamic_cast<PFMSpriteComponent*>(component);
PFMSprite* sprite = PFMSprite::createWithComponent(spriteComponent);
Size size = sprite->getBoundingBox().size;
PhysicsBody* physicsBody = PhysicsBody::createBox(sprite->getBoundingBox().size);
physicsBody->setCollisionBitmask(0);
physicsBody->setCategoryBitmask(PFMCollideMaskBitsPlayer);
physicsBody->setContactTestBitmask(PFMCollideMaskBitsEnemyBullet | PFMCollideMaskBitsEnemy);
setPhysicsBody(physicsBody);
addChild(sprite);
}
else if(component->componentClass == "BulletGun")
{
PFMBulletGunComponent* bulletGunComponent = dynamic_cast<PFMBulletGunComponent*>(component);
PFMBulletGun* bulletGun = PFMBulletGun::createWithComponent(bulletGunComponent);
bulletGun->isHostByPlayer = true;
bulletGun->isAutoShoot = true;
addChild(bulletGun);
}
// else if([component isMemberOfClass:[AstMissleLauncherComponent class]])
// {
// AstMissleLauncher* missleLauncher = [[AstMissleLauncher alloc]initWithSession:self.session];
// [self addNode:missleLauncher.rootNode];
// [missleLauncher setComponent:(AstMissleLauncherComponent*)component];
// }
}
}
示例8: init
bool HeroSprite::init() {
bool bRet = false;
do {
CC_BREAK_IF(!Sprite::initWithSpriteFrameName("heroStand_0001.png"));
Size heroSize = this->getContentSize();
PhysicsBody *body = PhysicsBody::createBox(heroSize-Size(0,16), PhysicsMaterial(0, 0, 0));
body->setLinearDamping(0.0f);
body->setDynamic(true);
body->setGravityEnable(true);
body->setTag(TAG_HERO_PHYS_BODY);
body->setCategoryBitmask(1<<2);
body->setContactTestBitmask(1<<0 | 1<<1);
body->setMass(50);
body->setRotationEnable(false);
this->setPhysicsBody(body);
mState = STATE_IDLE;
mRunAnimate = NULL;
mSmokeRunAnimate = NULL;
bRet = true;
} while(0);
return bRet;
}
示例9: init
bool Car::init(string fileName)
{
if (!Node::init())
return false;
//------------- Khởi tạo sprite chính -------------
_sprite = Sprite::create(fileName);
_sprite->setPosition(0, 0);
_sprite->setAnchorPoint(Vec2(0.25, 0.25));
this->addChild(_sprite);
//------------- Physic Body --------------
body = PhysicsBody::createBox(Size(_sprite->getContentSize().width / 2, _sprite->getContentSize().height / 2), PhysicsMaterial(100.0f, 0.0f, 100.0f), Vec2::ZERO);
body->setDynamic(false);
body->setTag(Tags::OBSTRUCTION);
body->setCollisionBitmask(1);
body->setContactTestBitmask(1);
this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
this->setPhysicsBody(body);
//Mai xe
auto nodeCar = Node::create();
nodeCar->setPosition(_sprite->getContentSize().width * 2.1 / 4, _sprite->getContentSize().height * 2.3 / 3);
nodeCar->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_sprite->addChild(nodeCar);
PhysicsBody * bodyNodeCar = PhysicsBody::createBox(Size(_sprite->getContentSize().width * 2.5 / 5, _sprite->getContentSize().height / 3), PhysicsMaterial(100.0f, 0.0f, 100.0f), Vec2::ZERO);
bodyNodeCar->setTag(Tags::MAIXE);
bodyNodeCar->setDynamic(false);
bodyNodeCar->setContactTestBitmask(1);
bodyNodeCar->setCollisionBitmask(1);
nodeCar->setPhysicsBody(bodyNodeCar);
//Score
auto nodeScore = Node::create();
nodeScore->setPosition(_sprite->getContentSize().width * 2.1 / 4, _sprite->getContentSize().height);
nodeScore->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_sprite->addChild(nodeScore);
PhysicsBody * bodyNodeScore = PhysicsBody::createBox(Size(_sprite->getContentSize().width * 2.5 / 5, Config::screenSize.height), PhysicsMaterial(100.0f, 0.0f, 100.0f), Vec2::ZERO);
bodyNodeScore->setTag(Tags::NODE_SCORE);
bodyNodeScore->setDynamic(false);
bodyNodeScore->setCategoryBitmask(0x01);
bodyNodeScore->setContactTestBitmask(1);
bodyNodeScore->setCollisionBitmask(0x02);
nodeScore->setPhysicsBody(bodyNodeScore);
return true;
}
示例10: init
bool Rock::init()
{
if (!Sprite::initWithFile("rock.png"))
{
return false;
}
PhysicsBody* rockBody = PhysicsBody::createBox(this->getContentSize(), PhysicsMaterial(DEFAULT_ROCK_MATERIAL));
rockBody->setDynamic(false);
rockBody->setContactTestBitmask(ROCK_CONTACT_MASK);
rockBody->setCategoryBitmask(ROCK_CATEGORY);
rockBody->setCollisionBitmask(ROCK_COLLISION_MASK);
rockBody->setGravityEnable(false);
this->setPhysicsBody(rockBody);
return true;
}
示例11: addBallObstacle
/*
auto ball = Sprite::create("Ball.png");
PhysicsBody *ballbody = PhysicsBody::create();
ballbody->addShape(PhysicsShapeCircle::create(BIRD_RADIUS+5));
ballbody->setCategoryBitmask(ColliderTypeBird);
ballbody->setCollisionBitmask(ColliderTypeLand | ColliderTypePip);
ballbody->setContactTestBitmask(1);
ballbody->setDynamic(true);
ballbody->setLinearDamping(0.0f);
ballbody->setGravityEnable(true);
ball->setPhysicsBody(ballbody);
auto visibleSize = Director::getInstance()->getVisibleSize();
ball->setPosition(bird->getPositionX()+2*20,visibleSize.height);
addChild(ball);
*/
void GameLayer::addBallObstacle(float dt)
{
auto ball = Sprite::create("Ball.png");
PhysicsBody *ballbody = PhysicsBody::create();
ballbody->addShape(PhysicsShapeCircle::create(BIRD_RADIUS+5));
ballbody->setCategoryBitmask(ColliderTypeBall);
ballbody->setCollisionBitmask(ColliderTypeLand | ColliderTypePip | ColliderTypeBird | ColliderTypeBall);
ballbody->setContactTestBitmask(ColliderTypeBird);
ballbody->setDynamic(true);
ballbody->setLinearDamping(0.0f);
ballbody->setGravityEnable(true);
ball->setPhysicsBody(ballbody);
auto visibleSize = Director::getInstance()->getVisibleSize();
ball->setPosition(bird->getPositionX()+2*20,visibleSize.height);
addChild(ball);
}
示例12: init
void MonsterPart::init(Monster * _parent, cocos2d::Layer * layer, cocos2d::Vec2 _pos , std::string spriteName, float _sInterval , int zLayer , bool ifPhysics , BulletType _bulletType)
{
// init parameter
if (_parent != NULL)
{
setPartent(_parent);
}else
parent = NULL;
shootInterval = _sInterval;
this->bulletType = _bulletType;
// set up the sprite
pos = _pos;
sprite = Sprite::create(spriteName);
sprite->setScale(0.5);
if (parent != NULL)
{
sprite->setPosition(parent->getRelatedPos(pos));
sprite->setColor(parent->color);
}
layer->addChild(sprite, zLayer);
// if (ifPhysics)
{
// 1
auto monsterSize = sprite->getContentSize();
PhysicsBody* body = PhysicsBody::createBox(Size(monsterSize.width , monsterSize.height),PhysicsMaterial(0.1f, 1.0f, 0.0f));
// 2
body->setDynamic(true);
// 3
body->setCategoryBitmask(PhysicsCategory::Part);
body->setCollisionBitmask((int)PhysicsCategory::None);
body->setContactTestBitmask((int)PhysicsCategory::MonsterA);
UserData* data = new UserData();
data->part = this;
sprite->setUserData((void*)data);
sprite->setPhysicsBody(body);
}
}
示例13: init
bool Buff::init(int type)
{
char txt[100];
_type = type;
sprintf(txt, "buff%d.png", type);
if (!Sprite::initWithFile(txt)) {
return false;
}
this->setTag(TYPE::BUFF);
auto size = (this->getBoundingBox()).size;
auto material = PhysicsMaterial(100.0f, 0.01f, 1.0f);
PhysicsBody *body = PhysicsBody::createBox(Size(size.width,size.height),material);
// body->addShape(PhysicsShapeBox::create(Size(size.width,size.height),material));
body->setCategoryBitmask(TYPE::BUFF);
body->setCollisionBitmask(0);
body->setContactTestBitmask(TYPE::BUFF | TYPE::HERO);
body->setDynamic(false);
body->setRotationEnable(false);
this->setPhysicsBody(body);
return true;
}
示例14: init
bool GameLayer::init() {
if (!Layer::init()) {
return false;
}
this->score = 0;
this->gameStatus = GameStatus::GAME_RUNNING;
this->bestScore = UserDefault::getInstance()->getIntegerForKey(KEY);
visibleSize = Director::getInstance()->getVisibleSize();
//创建小鸟
this->bird = BirdSprite::getInstance();
this->bird->createBird();
//创建物理属性
PhysicsBody *body = PhysicsBody::createCircle(15);
//设置为受到重力影响的动态刚体
body->setDynamic(true);
//设置线性阻尼
body->setLinearDamping(0.0f);
//设置刚体是否受物理世界重力的影响
body->setGravityEnable(false);
//设置形状的恢复系数
//body->getShape(0)->setRestitution(0.0f);
body->getShape(0)->setDensity(1.0f);
//设置所属种类的掩码值
body->setCategoryBitmask(BIRD_MASK);
body->setCollisionBitmask(BIRD_MASK | OBST_MASK);
body->setContactTestBitmask(BIRD_MASK | OBST_MASK);
this->bird->setPhysicsBody(body);
this->bird->setPosition(visibleSize.width / 3, visibleSize.height / 2);
this->bird->idle();
this->bird->fly();
this->addChild(this->bird, 2);
//添加陆地物理属性
auto land = Node::create();
landHeight = BackgroundLayer::getLandHeight();
auto landBody = PhysicsBody::createBox(Size(visibleSize.width, landHeight));
landBody->getShape(0)->setRestitution(0.0f);
landBody->setDynamic(false);
landBody->setGravityEnable(false);
landBody->setCategoryBitmask(OBST_MASK);
landBody->setCollisionBitmask(BIRD_MASK | OBST_MASK);
landBody->setContactTestBitmask(BIRD_MASK | OBST_MASK);
land->setPhysicsBody(landBody);
land->setPosition(visibleSize.width / 2, landHeight / 2);
this->addChild(land, 10);
//添加碰撞监听
auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = CC_CALLBACK_1(GameLayer::onContactBegin, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);
this->createPips();
this->scheduleUpdate();
this->schedule(schedule_selector(GameLayer::scrollPipe), 0.01f);
return true;
}
示例15: addChild
// on "init" you need to initialize your instance
bool Level_8::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 visiblePoint = Director::getInstance()->getVisibleOrigin();
root_level = CSLoader::createNode("Scene/LevelScene/Level_8.csb");
root_level->setTag(100001);
this->addChild(root_level);
//设置物理 空心世界
PhysicsBody* psworld =PhysicsBody::createEdgeBox(visibleSize*1.5,PHYSICSBODY_MATERIAL_DEFAULT,2);
psworld->setCategoryBitmask(0x01);
psworld->setCollisionBitmask(0x01);
psworld->setContactTestBitmask(0x01);
root_level->setPhysicsBody(psworld);
//车
Sprite* maincar = root_level->getChildByName<Sprite*>("img_maincarbody_17");
//退出
Sprite* mainexit = root_level->getChildByName<Sprite*>("img_next_14");
//创建主要UI界面
mainui = MainUI::create();
auto maincar_r = MainCar_R::create();
mainui->setCar_R(maincar_r);
maincar_r->setMainUI(mainui);
maincar_r->setObj(maincar);
addChild(maincar_r,10);
addChild(mainui,3000);
//退出
Exit* eit = Exit::create();
eit->setObj(mainexit);
addChild(eit);
//添加地面的刚体
Sprite* gound_1 = root_level->getChildByName<Sprite*>("l8_gound_1_1");
Sprite* gound_2 = root_level->getChildByName<Sprite*>("l8_gound_2_1");
Sprite* gound_3 = root_level->getChildByName<Sprite*>("l8_gound_3_1");
Sprite* gound_4 = root_level->getChildByName<Sprite*>("l8_gound_4_1");
Sprite* gound_5 = root_level->getChildByName<Sprite*>("l8_gound_5_1");
Sprite* gound_6 = root_level->getChildByName<Sprite*>("l8_gound_6_1");
Sprite* gound_7 = root_level->getChildByName<Sprite*>("l8_gound_7_1");
Sprite* gound_14 = root_level->getChildByName<Sprite*>("l8_gound_14_1");
//////////////////////////////////////////////////////////////////////
Sprite* gound_8 = root_level->getChildByName<Sprite*>("l8_gound_8_1");
Sprite* gound_9 = root_level->getChildByName<Sprite*>("l8_gound_9_1");
Sprite* gound_10 = root_level->getChildByName<Sprite*>("l8_gound_10_1");
Sprite* gound_11 = root_level->getChildByName<Sprite*>("l8_gound_11_1");
Sprite* gound_12 = root_level->getChildByName<Sprite*>("l8_gound_12_1");
Sprite* gound_13 = root_level->getChildByName<Sprite*>("l8_gound_13_1");
ToolsFunction::setPhyDynamicSpriteBox(gound_1);
ToolsFunction::setPhyDynamicSpriteBox(gound_2);
ToolsFunction::setPhyDynamicSpriteBox(gound_3);
ToolsFunction::setPhyDynamicSpriteBox(gound_4);
ToolsFunction::setPhyDynamicSpriteBox(gound_5);
ToolsFunction::setPhyDynamicSpriteBox(gound_6);
ToolsFunction::setPhyDynamicSpriteBox(gound_7);
ToolsFunction::setPhyDynamicSpriteBox(gound_14);
//四个二维数组点 组成多边形
Vec2 pa[3] = {
Vec2(-gound_13->getContentSize().width/2,-gound_13->getContentSize().height/2),
Vec2(-gound_13->getContentSize().width/2+2,gound_13->getContentSize().height/2-2),
Vec2(-gound_13->getContentSize().width/3+120 ,-gound_13->getContentSize().height/2)};
auto aa = PhysicsBody::createPolygon(pa, 3);
// aa->setCategoryBitmask(0x03);
// aa->setCollisionBitmask(0x03);
// aa->setContactTestBitmask(0x03);
aa->setDynamic(false);
//aa->setLinearDamping(5000.0f);
gound_13->setPhysicsBody(aa);
//按钮 1
Button* b1 = root_level->getChildByName<Button*>("Button_1");
Button* b2 = root_level->getChildByName<Button*>("Button_2");
Button* b3 = root_level->getChildByName<Button*>("Button_3");
Sprite* b4 = root_level->getChildByName<Sprite*>("Button_4");
Sprite* b5 = root_level->getChildByName<Sprite*>("Button_5");
//按钮问题
Sprite* q1 = root_level->getChildByName<Sprite*>("question_1");
Sprite* q2 = root_level->getChildByName<Sprite*>("question_2");
Sprite* q3 = root_level->getChildByName<Sprite*>("question_3");
Sprite* q4 = root_level->getChildByName<Sprite*>("question_4");
Sprite* q5 = root_level->getChildByName<Sprite*>("question_5");
//创建颜色按钮 4个按钮
QuestionButton* btn_1 = QuestionButton::create();
btn_1->setObj(b1);
addChild(btn_1,5);
QuestionButton* btn_2 = QuestionButton::create();
btn_2->setObj(b2);
addChild(btn_2,5);
QuestionButton* btn_3 = QuestionButton::create();
btn_3->setObj(b3);
addChild(btn_3,5);
Btn_Standard* btn_4 = Btn_Standard::create();
btn_4->setObj(b4);
addChild(btn_4,5);
Btn_Standard* btn_5 = Btn_Standard::create();
btn_5->setObj(b5);
addChild(btn_5,5);
//.........这里部分代码省略.........