本文整理汇总了C++中ParticleSystemQuad::setAutoRemoveOnFinish方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystemQuad::setAutoRemoveOnFinish方法的具体用法?C++ ParticleSystemQuad::setAutoRemoveOnFinish怎么用?C++ ParticleSystemQuad::setAutoRemoveOnFinish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystemQuad
的用法示例。
在下文中一共展示了ParticleSystemQuad::setAutoRemoveOnFinish方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onCollision
COLL_RET Bullet::onCollision(cocos2d::Node *other)
{
const int otherTag = other->getTag();
if (otherTag == COLL_TILE_GRASS
|| otherTag == COLL_TILE_WATER
|| otherTag == COLL_REBIRTH
|| otherTag == COLL_AWARDS)
return RETAIN;
if (COLL_EDGE_BOTTOM == otherTag
||COLL_EDGE_LEFT == otherTag
||COLL_EDGE_RIGHT == otherTag
||COLL_EDGE_TOP == otherTag)
{
return DESTROY;
}
if (COLL_BULLET == _tag || COLL_BULLET_IRON == _tag)
{
if (otherTag != COLL_FELLOWS &&otherTag != COLL_BULLET &&otherTag != COLL_BULLET_IRON)
{
ParticleSystemQuad * particle = ParticleSystemQuad::create("bullet_exp.plist");
Sprite *tmpSprite = Sprite::createWithSpriteFrameName("bullet_exp.png");
tmpSprite->setVisible(false);
particle->setTextureWithRect(tmpSprite->getTexture(), tmpSprite->getTextureRect());
particle->addChild(tmpSprite);
particle->setScale(0.05f);
particle->setPosition(this->getPosition());
this->getParent()->addChild(particle, 2);
particle->setAutoRemoveOnFinish(true);
return DESTROY;
}
}
else if (COLL_BULLET_ENEMIES == _tag)
{
if (otherTag != COLL_ENEMIES && otherTag != COLL_BULLET_ENEMIES)
{
ParticleSystemQuad * particle = ParticleSystemQuad::create("bullet_exp.plist");
Sprite *tmpSprite = Sprite::createWithSpriteFrameName("bullet_exp.png");
tmpSprite->setVisible(false);
particle->setTextureWithRect(tmpSprite->getTexture(), tmpSprite->getTextureRect());
particle->addChild(tmpSprite);
particle->setScale(0.05f);
particle->setPosition(getPosition());
this->getParent()->addChild(particle, 2);
particle->setAutoRemoveOnFinish(true);
return DESTROY;
}
}
return RETAIN;
}
示例2: touchEnded
void BirdMode::touchEnded(Touch *touch) {
auto emitPtr = _touches.find(touch);
ParticleSystemQuad *emit = nullptr;
auto touchPos = this->convertToNodeSpace(touch->getLocation());
if (emitPtr != _touches.end()) {
emit = emitPtr->second.emitter;
touchPos.x = XtoAB(touchPos.x, getChordMaxX(), getNoteMaxX());
noteTouchEnded(getTouchLocation(touchPos), &emitPtr->second);
}
else if (firstTouch.first == touch) {
emit = firstTouch.second.emitter;
touchPos.x = XtoAB(touchPos.x, 0, getChordMaxX());
chordTouchEnded(getTouchLocation(touchPos), &firstTouch.second);
firstTouch.first = 0;
}
else
return;
if (emit) {
emit->setPosition(touchPos);
emit->setDuration(0.2);
emit->setSpeed(emit->getSpeed() * 2);
emit->setAutoRemoveOnFinish(true);
_touches.erase(touch);
}
}
示例3: isCollisionWithCoin
bool GameScene::isCollisionWithCoin() //和金币的碰撞检测
{
bool aFlag = false;
for (int i=0; i<coinArray.size(); i++) {
Rect box = coinArray.at(i)->boundingBox();
if (player->boundingBox().intersectsRect(box))
{
//当金币可见的时候才放粒子效果和音效
if ( coinArray.at(i)->isVisible() == true) {
coinArray.at(i)->setVisible(false);
//粒子效果
ParticleSystemQuad *paritcle = ParticleSystemQuad::create("physic-con.plist");
paritcle->setPosition(coinArray.at(i)->getPosition());
paritcle->setAutoRemoveOnFinish(true);
this->addChild(paritcle,8);
this->progressUpdate();//调用进度条事件
player->addScore(1);//加分
if (isPlaySound) {
SimpleAudioEngine::getInstance()->playEffect("eatcoin.caf");
}
}
}
}
return aFlag;
}
示例4: showStarAni
void PBase::showStarAni(WJSprite *starSprite)
{
if (WJUtils::equals(starSprite->getUserString(), "get"))
{
starSprite->setVisible(true);
}
else
{
Common::sound.play("Common:star");
// 添加星星出现的粒子效果
ParticleSystemQuad *starParticle = ParticleSystemQuad::create("particles/star.plist");
starParticle->setPosition(Vec2(starSprite->getContentSize().width / 2, starSprite->getContentSize().height / 2));
starSprite->addChild(starParticle);
starParticle->setAutoRemoveOnFinish(true);
starSprite->setUserString("get");
starSprite->runAction(
Sequence::create(
ScaleTo::create(0.0f, 0.0f, 0.0f),
Show::create(),
Spawn::create(
ScaleTo::create(0.3f, 1.0f, 1.0f),
RotateBy::create(0.3f, 360.0f, 360.0f),
NULL),
NULL));
}
}
示例5: fire
void TankStateBullet::fire()
{
int starNum = _tankSprite->getBulletAwardNum();
if (_tankSprite->CanFire() && _tankSprite->getBulletNum() < 2){
CCLOG("TankNode sprite fire");
if (starNum >= 2)
{
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(FileUtils::getInstance()->fullPathForFilename("audio/btndir.wav").c_str());
_tankSprite->setBulletSpeed(_bulletSpeedBackup * 2.0f);
if (3 == starNum)
{
_tankSprite->setBulletTag(NodeWithCollision::COLL_BULLET_IRON);
}
}
else{
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(FileUtils::getInstance()->fullPathForFilename("audio/bullet.wav").c_str());
}
Bullet *norBullet = Bullet::create(MAPDATA->getCollDetector(), _tank);
_tankSprite->getParent()->addChild(norBullet, -1);
ParticleSystemQuad * particle = ParticleSystemQuad::create("bullet_smoke.plist");
Sprite *tmpSprite = Sprite::createWithSpriteFrameName("bullet_smoke.png");
tmpSprite->setVisible(false);
particle->setTextureWithRect(tmpSprite->getTexture(), tmpSprite->getTextureRect());
particle->addChild(tmpSprite);
particle->setScale(0.2f);
particle->setPosition(norBullet->getPosition());
_tank->getParent()->addChild(particle, 2);
particle->setAutoRemoveOnFinish(true);
_tankSprite->insertBullet(norBullet);
}
}
示例6: addExplosionEffect
void BattleScene::addExplosionEffect(Vec2 point)
{
std::string fileName="boxBreak.plist";
ParticleSystemQuad *effect = ParticleSystemQuad::create(fileName);
auto scene =Director::getInstance()->getRunningScene();
if (scene) {
scene->addChild(effect,1000);
}
effect->setAutoRemoveOnFinish(true);
effect->setPosition(point);
}
示例7: testCollin
//碰撞检测
void StartGame::testCollin(float dt){
auto visibleSize=Director::getInstance()->getWinSize();
__Array *tempItemArray=__Array::create();
tempItemArray->retain();
Item *item;
for (int i=0; i<itemArray->count(); i++) {
item=(Item*)itemArray->getObjectAtIndex(i);
if (Tools::isCollision(hook, item)&&!hook->hookAction&&!item->itemAction) {
hook->stopAllActions();
miner->MinerAction();
tempItemArray->addObject(item);
hook->hookAction = true;
item->itemAction=true;
if (toggle->getSelectedIndex()==1) {
dt=0.5;
}else{
dt=2.0;
}
auto move=MoveTo::create(dt, Vec2(visibleSize.width/2-5,visibleSize.height/2-20));
auto call=CallFunc::create(CC_CALLBACK_0(StartGame::move, this));
auto sequence=Sequence::create(move,call, NULL);
hook->runAction(sequence);
if (item->itemAction) {
item->setRotation(hook->getRotation());
item->setAnchorPoint(Point(0.5, 1));
hook->setAnchorPoint(Point(0.5, 0.7));
item->setPosition(hook->getPosition());
hook->setAnchorPoint(Point(0.5, 1));
}
if (item->_type==diamond||item->_type==secret) {
ParticleSystemQuad* quad = ParticleSystemQuad::create("Boom.plist");
quad->setBlendAdditive(true);
quad->setAutoRemoveOnFinish(true);
quad->setPosition(item->getPosition());
quad->setDuration(0.2);
this->addChild(quad);
}
auto move1=MoveTo::create(dt, Vec2(visibleSize.width/2-5,visibleSize.height/2-20));
auto call1=CallFuncN::create(CC_CALLBACK_1(StartGame::removeItem, this));
auto sequence1=Sequence::create(move1,call1, NULL);
item->runAction(sequence1);
}
}
itemArray->removeObjectsInArray(tempItemArray);
tempItemArray->release();
}
示例8: StageEffect
void Result::StageEffect(float dt){
Size visibleSize = Director::getInstance()->getVisibleSize();
ParticleSystemQuad* particle = CCParticleSystemQuad::create("highscoretexture.plist");
particle->setAutoRemoveOnFinish(true);
int px=arc4random()%500;
int py=arc4random()%400+80;
// パーティクルを表示する場所の設定
particle->setPosition(Point((visibleSize.width-px)/2+px,visibleSize.height-py));
particle->setPositionZ(-3);
CCLOG("px=%d,py=%d",px,py);
// パーティクルを配置
this->addChild(particle);
}
示例9: createParticle
// ParticleSystemQuad : ParticleSystem : Node, (TextureProtocol : BlendProtocol)
// ParticleBatchNode : Node, (TextureProtocol : BlendProtocol)
ParticleSystemQuad* BaseScene::createParticle(int type){
int i = 0;
ParticleSystemQuad* particle = nullptr;
if (type == i++) {
particle = ParticleExplosion::create();
particle->setAutoRemoveOnFinish(true);
}
else if (type == i++) particle = ParticleFire::create();
else if (type == i++) particle = ParticleFireworks::create();
else if (type == i++) particle = ParticleFlower::create();
else if (type == i++) particle = ParticleGalaxy::create();
else if (type == i++) particle = ParticleMeteor::create();
else if (type == i++) particle = ParticleRain::create();
else if (type == i++) particle = ParticleSmoke::create();
else if (type == i++) particle = ParticleSnow::create();
else if (type == i++) particle = ParticleSpiral::create();
else if (type == i++) particle = ParticleSun::create();
return particle;
}
示例10: playMakeupParticle
void PrincessModel::playMakeupParticle(const char* particleName, int index)
{
Rect rect = m_skeleton->getContentRectInWorld();
Vec2 pos = Vec2::ZERO;
if (index == 0)
pos = Vec2(rect.origin.x + rect.size.width * 0.5f, rect.origin.y + rect.size.height * 0.85f);
else if (index == 1)
pos = Vec2(rect.origin.x + rect.size.width * 0.5f, rect.origin.y + rect.size.height * 0.75f);
else if (index == 2)
pos = Vec2(rect.origin.x + rect.size.width * 0.5f, rect.origin.y + rect.size.height * 0.6f);
pos = m_skeleton->convertToNodeSpace(pos);
ParticleSystemQuad *particle = ParticleSystemQuad::create(particleName);
particle->setPosition(pos + Vec2(0, -180));
particle->setPositionType(ParticleSystem::PositionType::RELATIVE);
particle->setAutoRemoveOnFinish(true);
m_skeleton->addChild(particle, 2000);
}
示例11: selectTouchEvent
void SelectHeroLayer::selectTouchEvent(Ref* pSender, Widget::TouchEventType type)
{
if( type == Widget::TouchEventType::ENDED)
{
Layout* selectItem = static_cast<Layout*>(pSender);
//删除上次的粒子效果
for(Widget* item : lstHero->getItems() )
{
ImageView* imgHero = static_cast<ImageView*>(Helper::seekWidgetByName(item, "imgHero"));
imgHero->removeAllChildren();
}
ImageView* imgHero = static_cast<ImageView*>(Helper::seekWidgetByName(selectItem, "imgHero"));
ParticleSystemQuad* particle = ParticleSystemQuad::create("particle_texture.plist");
particle->setAutoRemoveOnFinish(true);
imgHero->addChild(particle);
particle->setPosition( Vec2(50 , 50) );
_selectedHero = static_cast<HeroModel*>(selectItem->getUserObject());
}
}
示例12: update
void ChainReactionScene::update(float df)
{
for ( size_t i = 0; i < _ballClones.size(); ++i )
{
_ballClones[i]->update(df);
if ( _lastExplosion && Util::collides(_lastExplosion, _ballClones[i] ) )
{
++_chainedExplosionCount;
ParticleSystemQuad* particleSystem = ParticleExplosion::create();
this->addChild(particleSystem, 10);
particleSystem->setTexture( Director::getInstance()->getTextureCache()->addImage("Stars2.png") );
particleSystem->setAutoRemoveOnFinish(true);
particleSystem->setPosition( _ballClones[i]->getPosition() );
particleSystem->setDuration(1.0f);
// Update the score
_currenPlayerScore->addPoints(_chainedExplosionCount);
log("Removing child %zi", i + 1);
removeChild(_ballClones[i]);
_ballClones.erase( _ballClones.begin() + i );
}
}
}
示例13: init
bool StartGame:: init(){
if (!Layer::init()) {
return false;
}
itemArray=__Array::create();
itemArray->retain();
int k=arc4random()%6+1;
std::string str= StringUtils::format("mineBG%d.png",k);
auto visibleSize=Director::getInstance()->getVisibleSize();
auto sprite=Sprite::create(str);
sprite->setPosition(visibleSize.width/2,visibleSize.height/2);
this->addChild(sprite);
//离子
ParticleSystemQuad* quad = ParticleSystemQuad::create("fengye.plist");
quad->setBlendAdditive(true);
quad->setAutoRemoveOnFinish(true);
quad->setPosition(Vec2(400, 300));
this->addChild(quad);
//黄金
char a[50];
sprintf(a, "%d",score[level-1]);
auto sprite1=Sprite::create("Gold.png");
sprite1->setPosition(visibleSize.width/2-200,visibleSize.height/2+130);
auto lable1=Label::createWithSystemFont(a, "fonts/Marker Felt.ttf ", 28);
lable1->setTextColor(Color4B::GREEN);
lable1->setPosition(visibleSize.width/2-150,visibleSize.height/2+130);
lable1->setTag(10);
this->addChild(lable1);
this->addChild(sprite1);
//钱
auto sprite2=Sprite::create("rmbImage.png");
sprite2->setPosition(visibleSize.width/2-200,visibleSize.height/2+90);
auto lable2=Label::createWithSystemFont("0", "fonts/Marker Felt.ttf ", 28);
lable2->setPosition(visibleSize.width/2-150,visibleSize.height/2+90);
lable2->setTag(20);
lable2->setTextColor(Color4B::RED);
this->addChild(lable2);
this->addChild(sprite2);
//矿工
auto sprite3=Sprite::create("miner_0707.png");
sprite3->setPosition(visibleSize.width/2+180,visibleSize.height/2+130);
char c[50];
sprintf(c, "%d",level);
auto lable3=Label::createWithSystemFont(c, "fonts/Marker Felt.ttf ", 28);
lable3->setPosition(visibleSize.width/2+220,visibleSize.height/2+130);
lable3->setTag(30);
lable3->setTextColor(Color4B::GREEN);
this->addChild(lable3);
this->addChild(sprite3);
char d[50];
sprintf(d, "%d",totalTime[level-1]);
auto sprite4=Sprite::create("clockPlate.png");
sprite4->setTag(4);
sprite4->setPosition(visibleSize.width/2+180,visibleSize.height/2+90);
auto lable4=Label::createWithSystemFont(d, "fonts/Marker Felt.ttf ", 28);
lable4->setPosition(visibleSize.width/2+220,visibleSize.height/2+90);
lable4->setTag(40);
lable4->setTextColor(Color4B::GREEN);
this->addChild(lable4);
this->addChild(sprite4);
auto item=MenuItemImage::create("qianglishui.png", "qianglishui.png");
auto item1=MenuItemImage::create("qianglishui.png", "qianglishui.png");
toggle=MenuItemToggle::create();
toggle->addSubItem(item);
toggle->addSubItem(item1);
toggle->setScale(0.5);
toggle->setSelectedIndex(0);
toggle->setCallback([this](Ref*){
//减少PowerWater数量
auto lable=(Label*)this->getChildByTag(50);
int num= atoi(lable->getString().c_str());
if (num!=0){
Water--;
miner->setScale(1.5);
//this->schedule(schedule_selector(StartGame::changeSelect),8);
this->schedule(CC_CALLBACK_1(StartGame::changeSelect,this), 8, "changeSelect");
lable->setString(StringUtils::format("%d",Water));
this->testCollin(1.0);
}else if(num==0){
toggle->setSelectedIndex(0);
log("%d",toggle->getSelectedIndex());
}
});
menu=Menu::create(toggle, NULL);
menu->setPosition(Vec2(visibleSize.width/2+180, visibleSize.height/2+50));
std::string str1= StringUtils::format("%d",Water);
lable5=Label::createWithSystemFont(str1,"fonts/Marker Felt.ttf", 28);
lable5->setPosition(Vec2(visibleSize.width/2+220, visibleSize.height/2+50));
lable5->setTag(50);
lable5->setTextColor(Color4B::GREEN);
this->addChild(lable5);
//.........这里部分代码省略.........
示例14: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(label, 1);
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(sprite, 0);
// 第一种方式直接使用Cocos的API,然后指定图片资源,然后add进scene就可以了
// ParticleSnow
// ParticleFire
// ParticleFlower
// ParticleGalaxy
// ParticleMeteor
// ParticleRain
// ParticleSmoke
// ParticleSpiral
// ParticleSun
/*
ParticleSystem* particle = ParticleSun::create();
particle->setTexture(TextureCache::sharedTextureCache()->addImage("res/laugh.png"));
this->addChild(particle);
*/
// 第二种方式
ParticleSystemQuad* quad = ParticleSystemQuad::create("particles/Upsidedown.plist");
quad->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
quad->setAutoRemoveOnFinish(true);
this->addChild(quad);
return true;
}