本文整理汇总了C++中ParticleSystemQuad::getTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemQuad::getTexture方法的具体用法?C++ ParticleSystemQuad::getTexture怎么用?C++ ParticleSystemQuad::getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemQuad
的用法示例。
在下文中一共展示了ParticleSystemQuad::getTexture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GameScene::init()
{
if (!Layer::init()) {
return false;
}
Size winSize =Director::getInstance()->getWinSize();
ParticleSystemQuad* qual = ParticleSystemQuad::create("res/effect/dots_birth.plist");
ParticleBatchNode* bNode = ParticleBatchNode::createWithTexture(qual->getTexture());
bNode->addChild(qual);
this->addChild(bNode);
qual->setPosition(Vec2(320,568));
auto spawnHero = CallFunc::create([=]()
{
m_hero = Hero::create();
this->addChild(m_hero);
addJointForHero();
bNode->removeFromParent();
});
auto spawnMobs = CallFunc::create([=]()
{
Enemy* enemy = Enemy::create();
enemy->setPosition(Vec2(400,200));
addChild(enemy);
enemy->moveToHero(m_hero->getCurMovingNode()->getPosition());
});
auto spawnHeroSequ = Sequence::create(DelayTime::create(0.8),spawnHero,spawnMobs,NULL);
runAction(spawnHeroSequ);
EventListenerTouchOneByOne* listenner = EventListenerTouchOneByOne::create();
listenner->onTouchBegan = [=](Touch* touch,Event* evt)
{
m_hero->swapCircle();
Vec2 pos = m_hero->getCurMovingNode()->getPosition();
if( shoudMoveCameraPos(pos) )
m_camera->runAction(MoveTo::create(0.3,pos));
// m_hero->changeState();
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listenner,this);
Sprite* bg = Sprite::create("res/bg_1.png");
addChild(bg,-1);
bg->setPosition(winSize/2);
bg->setScale(2,3);
auto edge = Node::create();
edge->setPosition(winSize/2);
PhysicsBody* edgeBody = PhysicsBody::createEdgeBox(winSize*1.3,PhysicsMaterial(PHYSICS_INFINITY,0,0),10,Vec2(0,0));
edge->setPhysicsBody(edgeBody);
edgeBody->setDynamic(true);
addChild(edge);
edgeBody->setCategoryBitmask(0xFFFFFFFF);
edgeBody->setCollisionBitmask(0xFFFFFFFF);
edgeBody->setContactTestBitmask(0X00001000);
EventListenerPhysicsContact* physicsListenner = EventListenerPhysicsContact::create();
physicsListenner->onContactBegin=[=](PhysicsContact& contact)
{
//英雄和墙发生碰撞
if ((contact.getShapeA()->getContactTestBitmask()|contact.getShapeB()->getContactTestBitmask()) == 0x11001000)
{
m_hero->reverse();
}
//英雄和食物发生碰撞
else if ((contact.getShapeA()->getContactTestBitmask()|contact.getShapeB()->getContactTestBitmask()) == 0x11000100)
{
exchangeSide();
if ((contact.getShapeA()->getContactTestBitmask()) == 0x00000100)
{
contact.getShapeA()->getBody()->getNode()->setVisible(false);
}
else if((contact.getShapeB()->getContactTestBitmask()) == 0x00000100)
{
contact.getShapeB()->getBody()->getNode()->setVisible(false);
}
}
//英雄和怪物发生碰撞
else if ((contact.getShapeA()->getContactTestBitmask()|contact.getShapeB()->getContactTestBitmask())== 0x11000110)
{
Vec2 contactPos = contact.getContactData()->points[0];
ParticleSystemQuad* quad = ParticleSystemQuad::create("res/effect/die.plist");
quad->setPosition(contactPos);
ParticleBatchNode* batch = ParticleBatchNode::createWithTexture(quad->getTexture());
batch->addChild(quad);
addChild(batch);
auto removeFunc = CallFunc::create([=](){
batch->removeFromParent();
});
Sequence* sequ = Sequence::create(DelayTime::create(0.8f),removeFunc,NULL);
runAction(sequ);
}
return true;
};
physicsListenner->onContactPreSolve = [=](PhysicsContact& contact,PhysicsContactPreSolve& preSlove)
{
CCLOG("PreSlove");
return false;
};
physicsListenner->onContactPostSolve = [=](PhysicsContact& contact,const PhysicsContactPostSolve& postSlove)
{
CCLOG("PostSlove");
//.........这里部分代码省略.........