void Towers::towerLogic(float dt) { // if(_target==NULL){ _target = getClosestTarget(); // } if (_target != NULL) { //rotate the tower to face the nearest creep CCPoint shootVector = ccpSub(_target->getPosition(), getPosition()); float shootAngle = ccpToAngle(shootVector); float cocosAngle = CC_RADIANS_TO_DEGREES(-1 * shootAngle); float rotateSpeed = 0.5 / M_PI; // 1/2 second to roate 180 degrees float rotateDuration = fabs(shootAngle * rotateSpeed); runAction(CCSequence::create(CCRotateTo::create(rotateDuration,cocosAngle), CCCallFunc::create(this,callfunc_selector(Towers::finishFiring)),NULL)); } }
void GameData::GameSlowDown(float duration, bool isToBlack) { //减速比例 float rate = 0.3; Director::getInstance()->getScheduler()->setTimeScale(rate); ActionInterval* delay = DelayTime::create(duration*rate); CallFunc* func = CallFunc::create(this,callfunc_selector(GameData::GameResumeScale)); ActionInterval* seq = Sequence::create(delay,func,nullptr); Node* node = UIController::getInstance()->getPhysicsLayer(); node->runAction(seq); if (isToBlack) { //屏幕变黑 UIController::getInstance()->getPhysicsLayer()->ToBlack(duration); } }
void CommonProgressHUD::showHUD(CCObject* sender) { CCProgressHUD* hud = CCProgressHUD::show("Loading..."); hud->setPanelColor(ccc4(255, 0, 0, 200)); runAction(CCSequence::create(CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeMessage)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeRichMessage)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changePanelColor)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeDimColor)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::forceSquare)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeIcon)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::beforeHide)), CCDelayTime::create(2), CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::hide)), NULL)); }
bool GameOverLayer::init() { if (!CCLayerColor::initWithColor(ccc4(255, 255, 255, 255))) { return false; } CCSize winSize = CCDirector::sharedDirector()->getWinSize(); this->_label = CCLabelTTF::labelWithString("", "Arial", 12); this->_label->retain(); this->getLabel()->setColor(ccc3(0,0,0)); this->getLabel()->setPosition(ccp(winSize.width/2, winSize.height/2)); this->addChild(_label); this->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(3), CCCallFunc::actionWithTarget(this, callfunc_selector(GameOverLayer::gameOverDone)), NULL)); return true; }
void Player::ShowEmp() { destroyAll = true; empOne->setScale(1); empOne->setPosition(ccp(playerSprite->getPosition().x , playerSprite->getPosition().y + playerSprite->getContentSize().height/2)); this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(5), CCCallFunc::create(this, callfunc_selector(Player::DisableDestroyAll)))); empOne->runAction(CCSequence::create(CCScaleTo::create(0.5f, 10, 10), CCCallFuncN::create(this,callfuncN_selector(Player::HideEmp)), NULL)); empTwo->setScale(1); empTwo->setPosition(ccp(playerSprite->getPosition().x , playerSprite->getPosition().y + playerSprite->getContentSize().height/2)); empTwo->runAction(CCSequence::create(CCScaleTo::create(0.5f, 10, 10), CCCallFuncN::create(this, callfuncN_selector(Player::HideEmp)), NULL)); }
void CardSprite::initData(GameScene *gameScene, int level) { //CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, kCCMenuHandlerPriority); CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true); //this->setContentSize(CCSizeMake(100,134)); this->setgameScene(gameScene); CCLog("this->setgameScene(gameScene);"); m_isOpened = false; isReady = true; _level = level; _isDone = false; CCString* frameName = CCString::createWithFormat("%02d.png", _level); CCSprite* inCard = CCSprite::createWithSpriteFrameName(frameName->getCString()); inCard->setPosition(CCPointZero); inCard->setVisible(false); inCard->setTag(tag_inCard); addChild(inCard); CCSprite* outCard = CCSprite::createWithSpriteFrameName("back.png"); outCard->setPosition(CCPointZero); outCard->setTag(tag_outCard); addChild(outCard); CCFiniteTimeAction *releaseFunc = CCCallFunc::create(this, callfunc_selector(CardSprite::changeStatus)); m_openAnimIn = (CCActionInterval*)CCSequence::create(CCDelayTime::create(0.2f), //CCDelayTime::create(0.3f), CCShow::create(), CCOrbitCamera::create(0.2f, 1, 0, kInAngleZ, kInDeltaZ, 0, 0), NULL); m_openAnimIn->retain(); m_openAnimOut = (CCActionInterval *)CCSequence::create(CCOrbitCamera::create(0.2f, 1, 0, kOutAngleZ, kOutDeltaZ, 0, 0), CCHide::create(), CCDelayTime::create(0.2f), //CCDelayTime::create(2.5f), releaseFunc, NULL); m_openAnimOut->retain(); }
bool IntroLayer3::init() { if(!CCLayer::init()) return false; CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Menus/Intro/Intro.plist"); //CCSpriteFrame *firstFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bgIntro31.png"); CCSprite *firstFrame = CCSprite::create("Menus/Intro/bgIntro31.png"); this->addChild(firstFrame); CCSize size = CCDirector::sharedDirector()->getWinSize(); firstFrame->setPosition(ccp(size.width/2,size.height/2)); CCArray *frameArray = CCArray::create(); frameArray->retain(); for(int i =1;i<4;i++) { CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( CCString::createWithFormat("bgIntro3%d.png",i)->getCString() ); frameArray->addObject(frame); } CCAnimation *animation = CCAnimation::createWithSpriteFrames(frameArray,1.0f); CCAnimate *animate = CCAnimate::create(animation); CCAction *loopAction = CCSequence::create(animate,CCCallFunc::create(this,callfunc_selector(IntroLayer3::startGame)),NULL); loopAction->retain(); firstFrame->runAction(loopAction); //firstFrame->runAction() return true; }
bool Hero::init() { if (!ActionSprite::initWithSpriteFrameName("hero_idle_00.png")) { return false; } this->setCenterToBottom(39.0); this->setCenterToSides(29.0); this->setHitPoints(100.0); this->setDamage(20.0); this->setWalkSpeed(80.0); this->setRunSpeed(120.0); this->setJumpHight(60.0); this->setJumpNumLimit(2); Animation* idleAnimation = animationWithPrefix("hero_idle", 0, 6, 1.0 / 12.0); this->setIdleAction(RepeatForever::create(Animate::create(idleAnimation))); Animation* walkAnimation = animationWithPrefix("hero_walk", 0, 8, 1.0 / 12.0); this->setWalkAction(RepeatForever::create(Animate::create(walkAnimation))); Animation* runAnimation = animationWithPrefix("hero_run", 0, 8, 1.0 / 12.0); this->setRunAction(RepeatForever::create(Animate::create(runAnimation))); Animation* jumpAnimation = animationWithPrefix("hero_jump", 0, 6, 1.0 / 18.0); auto jumpAction = JumpBy::create(1.0/3.0, Vec2::ZERO, getJumpHight(), 1); auto action = Spawn::create(jumpAction, Animate::create(jumpAnimation), NULL); this->setJumpAction(Sequence::create(action, CallFunc::create(this, callfunc_selector(Hero::idle)), NULL)); Animation* attackAnimation = animationWithPrefix("hero_attack_00",0,2,1.0 / 24.0); //this->setAttackAction(RepeatForever::create(Animate::create(attackAnimation))); this->setAttackAction(Sequence::create(Animate::create(attackAnimation), CallFunc::create(this, callfunc_selector(Hero::idle)), NULL)); Animation* jumpAttackAnimation = animationWithPrefix("hero_jumpattack", 0, 5, 1.0 / 24.0); this->setJumpAttackAction(Sequence::create(Animate::create(jumpAttackAnimation), CallFunc::create(this, callfunc_selector(Hero::idle)), NULL)); Animation* runAttackAnimation = animationWithPrefix("hero_runattack", 0, 6, 1.0 / 24.0); this->setRunAttackAction(Sequence::create(Animate::create(runAttackAnimation), CallFunc::create(this, callfunc_selector(Hero::idle)), NULL)); return true; }
void GAMEUI_Scene::addDialog(GAMEUI_Dialog *dialog) { m_windowMask->setVisible(true); CCFadeTo * fade = CCFadeTo::create(0.2f, 0x80); m_windowMask->runAction(fade); if ( m_dialog == NULL ) { // Set this as the current dialog m_dialog = dialog; if ( m_ui ) { m_ui->pause(); } // [self switchUi:m_ui toUi:dialog]; // Show it now int z = m_dialog->getZOrder(); addChild(m_dialog, z+2); m_windowMask->setZOrder(z+1); CCCallFunc * finishAction = CCCallFunc::create(m_dialog, callfunc_selector(GAMEUI_Dialog::transitionInDone)); m_dialog->transitionIn(finishAction); } else { GAMEUI_Dialog * current = m_dialog; // Find the first dialog with no linked dialog while ( current != NULL && current->getNextDialog() != NULL ) { current = current->getNextDialog(); } // Store this as a linked dialog for later current->setNextDialog(dialog); } }
CAViewController* CANavigationController::popViewControllerAnimated(bool animated) { if (m_pViewControllers.size() == 1) { return NULL; } if (m_pContainer->getActionByTag(0)) { return NULL; } unsigned int index = m_pViewControllers.size() - 2; CAViewController* showViewController = m_pViewControllers.at(index); showViewController->getView()->setFrame(CCRectZero); m_pContainer->addSubview(showViewController->getView()); CAViewController* backViewController = m_pViewControllers.back(); float x = m_pContainer->getFrame().size.width; backViewController->getView()->setFrame(CCRect(x, 0, 0, 0)); if (animated) { m_pContainer->stopAllActions(); m_pContainer->setFrameOrigin(CCPoint(-x, m_pContainer->getFrameOrigin().y)); CCDelayTime* delayTime = CCDelayTime::create(0.2f); CCFrameOrginTo* moveTo = CCFrameOrginTo::create(0.4f, CCPoint(0, m_pContainer->getFrameOrigin().y)); CCEaseSineOut* easeBack = CCEaseSineOut::create(moveTo); CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::popViewControllerFinish)); CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL); m_pContainer->runAction(actions); actions->setTag(0); } else { this->popViewControllerFinish(); } return backViewController; }
void Stage1_6Layer::PlayerWithPropsBeginContactCallback( GameObject* player, CCSprite *ob, b2Contact* contact, b2Vec2 localNormalToPlayer ) { int obType = GET_TYPE(ob); int obTag = GET_TAG(ob); if(obType == kGameObjectUnkownBrick) { if(obTag == UNKNOWN_1 && localNormalToPlayer.y > 0) { UnknownBrick* brick = (UnknownBrick*)ob; ++m_nKnockOn1; if(m_nKnockOn1 <= TOTAL_COUNT - 2) { m_needToDo.push_back(callfunc_selector(Stage1_6Layer::refresh)); } if(m_nKnockOn1 == TOTAL_COUNT - 2) { m_needToDo.push_back(callfunc_selector(Stage1_6Layer::showAnother)); } else if(m_nKnockOn1 > TOTAL_COUNT - 2) { m_needToDo.push_back(callfunc_selector(Stage1_6Layer::tooYoungTooSimple)); } } if(obTag == UNKNOWN_2 && localNormalToPlayer.y > 0) { m_nKnockOn2 = 1; m_needToDo.push_back(callfunc_selector(Stage1_6Layer::refresh)); if(!m_bHasShowMonster) { m_bHasShowMonster = true; m_needToDo.push_back(callfunc_selector(Stage1_6Layer::showMonster)); } } if (obTag == UNKNOWN_3 && localNormalToPlayer.y > 0) { m_nKnockOn3 = 1; m_needToDo.push_back(callfunc_selector(Stage1_6Layer::refresh)); } } else if(obType == kGameObjectMonster) { gotoDead(); } // 这一句要写最后 PlatformStageLayer::PlayerWithPropsBeginContactCallback(player, ob, contact, localNormalToPlayer); }
void HitEffect::setVisible(bool isVisible) { this->isVisible = isVisible; sprite->setVisible(this->isVisible); sprite->setScale(1.0f); sprite->setOpacity(255 * 0.8); // 拡大 CCActionInterval* actionScale = CCScaleBy::create(0.15f, 5.0f); // フェードアウト CCActionInterval* actionAlpha = CCFadeOut::create(0.4f); // 非表示状態 cocos2d::CCCallFunc* actionNoVisible = cocos2d::CCCallFunc::create(this, callfunc_selector(HitEffect::setNoVisible)); // 処理順を並べる //CCSequence* actionFadeOut = CCSequence::create(actionAlpha, actionNoVisible); CCSequence* actionFadeOut = CCSequence::create(actionScale, actionNoVisible); //sprite->runAction(actionScale); sprite->runAction(actionFadeOut); }
void Recipe15::method1() { // CCCallFuncをシーケンスしたアクション作成 CCSequence* action1 = CCSequence::create( // CCCallFunc CCCallFunc::create(this, callfunc_selector(Recipe15::callback1)), // CCCallFuncN CCCallFuncN::create(this, callfuncN_selector(Recipe15::callback2)), // CCCallFuncND CCCallFuncND::create(this, callfuncND_selector(Recipe15::callback3), (void*)123), // 任意のデータのポインタを渡す // CCCallFuncO CCCallFuncO::create(this, callfuncO_selector(Recipe15::callback4), (CCObject*)CCString::create("text")), // CCObjectを渡す NULL); // スプライトの作成 CCSprite *player = CCSprite::create("monkey01.png"); this->addChild(player); // 作成したスプライトでアクションを実行 player->runAction(action1); }
//------------------------------------------------------------------ // // RemoveTest // //------------------------------------------------------------------ void RemoveTest::onEnter() { ActionManagerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* l = CCLabelTTF::labelWithString("Should not crash", "Thonburi", 16); addChild(l); l->setPosition( CCPointMake(s.width/2, 245) ); CCMoveBy* pMove = CCMoveBy::actionWithDuration(2, CCPointMake(200, 0)); CCCallFunc* pCallback = CCCallFunc::actionWithTarget(this, callfunc_selector(RemoveTest::stopAction)); CCActionInterval* pSequence = (CCActionInterval*) CCSequence::actions(pMove, pCallback, NULL); pSequence->setTag(kTagSequence); CCSprite* pChild = CCSprite::spriteWithFile(s_pPathGrossini); pChild->setPosition(CCPointMake(200, 200)); addChild(pChild, 1, kTagGrossini); pChild->runAction(pSequence); }
bool GameOverLayer::init() { if ( LayerColor::initWithColor(Color4B(0, 0, 0, 0)) ) { Size winSize = Director::getInstance()->getWinSize(); this->_label = LabelTTF::create("","Century Gothic", 90); _label->retain(); _label->setColor(Color3B (255, 255, 255)); _label->setPosition(Point(winSize.width/2, winSize.height/2)); this->addChild(_label); this->runAction( Sequence::create(DelayTime::create(3), CallFunc::create(this, callfunc_selector(GameOverLayer::gameOverDone)), NULL)); return true; } else { return false; } }
KDbool Explosion::init ( KDvoid ) { if ( !CCSprite::init ( ) ) { return KD_FALSE; } CCSpriteFrame* pFrame = CCSpriteFrameCache::sharedSpriteFrameCache ( )->spriteFrameByName ( "explosion_01.png" ); this->initWithSpriteFrame ( pFrame ); CCAnimation* pAnimation = CCAnimationCache::sharedAnimationCache ( )->animationByName ( "Explosion" ); this->runAction ( CCSequence::createWithTwoActions ( CCAnimate ::create ( pAnimation ), CCCallFunc::create ( this, callfunc_selector ( CCNode::removeFromParentAndCleanup ) ) ) ); return KD_TRUE; }
void CCTransitionTurnOffTiles::onEnter() { CCTransitionScene::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); float aspect = s.width / s.height; int x = (int)(12 * aspect); int y = 12; CCTurnOffTiles* toff = CCTurnOffTiles::create( ccg(x,y), m_fDuration); CCActionInterval* action = easeActionWithAction(toff); m_pOutScene->runAction ( CCSequence::create ( action, CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), CCStopGrid::create(), NULL ) ); }
void CANavigationController::replaceViewController(CrossApp::CAViewController *viewController, bool animated) { if (this->getView()->getSuperview() == NULL) { return; } if (m_pContainer->getActionByTag(0)) { return; } float x = m_pContainer->getFrame().size.width; CAViewController* lastViewController = m_pViewControllers.back(); lastViewController->getView()->setFrame(CCRect(-x, 0, 0, 0)); viewController->retain(); viewController->m_pNavigationController = this; m_pViewControllers.insert(m_pViewControllers.end()-1, viewController); viewController->addViewFromSuperview(m_pContainer); if (animated) { m_pContainer->stopAllActions(); m_pContainer->setFrameOrigin(CCPoint(x, m_pContainer->getFrameOrigin().y)); CCDelayTime* delayTime = CCDelayTime::create(0.5f); CCFrameOrginTo* moveTo = CCFrameOrginTo::create(0.4f, CCPoint(0, m_pContainer->getFrameOrigin().y)); CCEaseSineOut* easeBack = CCEaseSineOut::create(moveTo); CCCallFunc* finish = CCCallFunc::create(this, callfunc_selector(CANavigationController::replaceViewControllerFinish)); CCSequence* actions = CCSequence::create(delayTime, easeBack, finish, NULL); m_pContainer->runAction(actions); actions->setTag(0); } else { this->replaceViewControllerFinish(); } }
int PopupViewController::goBackPopupViewWithAnim(PopupBaseView *removeView,PopupBaseView *gobackView){ if (!gobackView) { return -1; } m_isPlayingInAnim = true; auto ArcPop = dynamic_cast<ArcPopupBaseView*>(gobackView); if (ArcPop) { UIComponent::getInstance()->showPopupView(1); } else { auto mailwrite = dynamic_cast<MailPopUpView*>(gobackView); if(mailwrite){ UIComponent::getInstance()->showPopupView(3); }else{ UIComponent::getInstance()->showPopupView(); } } auto popupLayer = SceneController::getInstance()->getCurrentLayerByLevel(LEVEL_POPUP_IN); // m_stack.insert(pair<int, PopupBaseView*> (++_view_count,gobackView)); // gobackView->_id = _view_count; // m_currentId = _view_count; gobackView->setUseAnimation(false); popupLayer->addChild(gobackView); //gobackView->release(); gobackView->setReturnPlayAnim(); removeView->setZOrder(1); float x = removeView->getPositionX()+removeView->getContentSize().width; float y = removeView->getPositionY(); // this->setPositionX(this->getPositionX()+this->getContentSize().width); CCMoveTo* userMove = CCMoveTo::create(0.2f, ccp(x,y)); removeView->runAction(CCSequence::create( CCEaseSineOut::create(userMove) , CCCallFunc::create(this, callfunc_selector(PopupViewController::whenPalyBackInAnim)) , NULL )); return _view_count; }
//受伤动画 void Monster::HurtAnimation(const char *name_each,const unsigned int num,bool run_directon) { if(IsHurt||Isdead) return; //受伤优先 if(IsRunning||IsAttack) { m_MonsterSprite->stopAllActions();//当前精灵停止所有动画 //恢复精灵原来的初始化贴图 this->removeChild(m_MonsterSprite,TRUE);//把原来的精灵删除掉 m_MonsterSprite=CCSprite::create(Monster_name);//恢复精灵原来的贴图样子 m_MonsterSprite->setFlipX(MonsterDirecton); this->addChild(m_MonsterSprite); IsRunning=false; IsAttack=false; } CCAnimation* animation = CCAnimation::create(); for( int i=1;i<=num;i++) { char szName[100] = {0}; sprintf(szName,"%s%d.png",name_each,i); animation->addSpriteFrameWithFileName(szName); //加载动画的帧 } animation->setDelayPerUnit(2.8f/14.0f); animation->setRestoreOriginalFrame(true); animation->setLoops(1); //动画循环1次 //将动画包装成一个动作 CCAnimate* act=CCAnimate::create(animation); //创建回调动作,受伤动画结束调用HurtEnd() CCCallFunc* callFunc=CCCallFunc::create(this,callfunc_selector(Monster::HurtEnd)); //创建连续动作 CCActionInterval* hurtackact=CCSequence::create(act,callFunc,NULL); m_MonsterSprite->runAction(hurtackact); IsHurt=true; }
void MonsterHaozhu::runByInfo() { bool isFlipX = false; switch (direction) { case DIRECTION_UP_LEFT: case DIRECTION_DOWN_RIGHT: isFlipX = true; break; case DIRECTION_UP_RIGHT: case DIRECTION_DOWN_LEFT: isFlipX = false; break; default: break; } this->SetAnim(runEffectInfo.effectId,1,true,this); this->SetAnimFlipX(isFlipX); CCPoint nowPoint = this->getPosition(); float distance = ccpDistance(getPosition(), runEffectInfo.endPosition); float speed = runEffectInfo.speed * 16; CCArray *arrayOfActions = CCArray::create(); CCMoveTo * move = CCMoveTo::create(distance / speed, runEffectInfo.endPosition); CCCallFunc * func = CCCallFunc::create(this, callfunc_selector(MonsterHaozhu::endRun)); arrayOfActions->addObject(move); arrayOfActions->addObject(func); CCFiniteTimeAction *sequence = CCSequence::create(arrayOfActions); m_rootSprite->stopAllActions(); m_rootSprite->runAction(sequence); }
void StarContainer::Refresh() { openList->clear(); closeList->clear(); for ( int i = 0 ; i < ROLE_NUM ; i++ ) { for ( int j = 0 ;j < ROLE_NUM ; j++ ) { if(m_pStars[i][j] == NULL) continue; GameMap::GetInstance()->getSpriteBatchBode()->removeChild(m_pStars[i][j]->GetAvata(),true); m_pStars[i][j] = new Star( RandomUtil::RangeInt(1,5)); CCSprite* sprite = m_pStars[i][j]->GetAvata(); CCMoveTo* moveTo = CCMoveTo::create( 0.7f , m_pStars[i][j]->getPosition( i , j )); CCEaseBounceOut* easeOut = CCEaseBounceOut::create(moveTo); CCCallFunc* callFunc = CCCallFunc::create(this,callfunc_selector(StarContainer::PlayStartAnimOver)); CCActionInterval* intervalAction = CCSequence::create( easeOut , callFunc , NULL ); sprite->runAction(intervalAction); GameMap::GetInstance()->getSpriteBatchBode()->addChild(sprite); } } }
void LevelEndView::showCoin2() { String coinFile = (coins_ > 1) ? "level_end_coin.png" : "level_end_coin_blank.png"; CCSprite* coinSprite = CCSprite::spriteWithSpriteFrameName(coinFile.c_str()); coinSprite->setPosition(ccp(240, 190)); addChild(coinSprite); float scaleTime = 0.1; CCFiniteTimeAction* coinSequence = CCSequence::actions ( CCScaleTo::actionWithDuration(scaleTime, 1.2), CCScaleTo::actionWithDuration(scaleTime, 1.0), CCCallFunc::actionWithTarget(this, callfunc_selector(LevelEndView::showCoin3)), NULL ); coinSprite->runAction(coinSequence); if (coins_ > 1) { String coinAwardEffect = String::withFormat("coin_award%d", coinAwardIndex_++); SoundSystem::sharedSoundSystem()->playEffect(coinAwardEffect); } }
void StoryInstanceDirector::PlayBecomeDarkEffect() { // Note: 播放黑屏特效 if (m_pColorLayer != 0) { m_pColorLayer->setVisible(true); float duration = 1.1f; CCFadeOut *fadeout = CCFadeOut::create(duration); m_pColorLayer->runAction(fadeout); MainMenuLayer * mLayer = GameManager::Get()->GetSceneLayer()->getMainMenuLayer(); CCCallFunc *rc = CCCallFunc::create(mLayer,callfunc_selector(MainMenuLayer::DarkEffectOver)); CCSequence *seq = (CCSequence*)CCSequence::create(CCDelayTime::create(duration),rc,NULL); if (mLayer) { mLayer->runAction(seq); } m_isPause = true; } }
void LyfTableViewCell::onTouchEnded(Touch *pTouch,Event *pEvent) { m_touchBeginUIPoint=Point::ZERO; Point uipoint=pTouch->getLocationInView(); Point point=Director::getInstance()->convertToGL(uipoint); point=this->convertToNodeSpace(point); do { CC_BREAK_IF(m_touchBegin == false); m_touchBegin = false; DelayTime* delayTime = DelayTime::create(0.1f); CallFunc* func = CallFunc::create(this, callfunc_selector(LyfTableViewCell::setNoTouchedEffect)); Sequence* actions = Sequence::create(delayTime, func, NULL); this->runAction(actions); actions->setTag(0xffff); } while (0); if (getRect().containsPoint(point) && m_touchModel==tCell) { m_delegate->setTouchPitchOn(this); } if (getBtnRect(m_imageView).containsPoint(point) && m_touchModel==tLead) { m_delegate->setTouchImageView(this); } if (getDelRect().containsPoint(point) && m_touchModel==tDel) { m_delBtn->setVisible(false); this->removeThisAndActions(); } }
void EnemyDarkCloud::update(float dt) { this->checkState(); Point heroPos = Hero::getInstance()->getPosition(); if (enemyState == eEnemyState_active) { if (leftSide <= heroPos.x && heroPos.x <= rightSide) { if (isDropable) { isDropable = false; this->addLighting(); this->runAction(Sequence::create(DelayTime::create(delay), CallFunc::create(this, callfunc_selector(EnemyDarkCloud::reSetDropable)), NULL)); } } } }
KDvoid CScrGame::setDamaged ( KDbool bOn ) { if ( bOn ) { CCFiniteTimeAction* pAction = CCSequence::create ( CCCallFunc::create ( g_pResMgr->getSound ( eSND_Player_Harm ), callfunc_selector ( CSound::Rewind ) ), CCFadeOut::create ( 1.f ), CCHide::create ( ), KD_NULL ); m_uiDamaged->runAction ( pAction ); m_uiDamaged->setOpacity ( 255 ); m_uiDamaged->setVisible ( KD_TRUE ); } else { m_uiDamaged->setVisible ( KD_FALSE ); m_uiDamaged->stopAllActions ( ); } }
void MonsterHaozhu::onEventMsgAttack(CCPoint serverPos, CCPoint direction, int animId, SkillInfo info) { SpriteMonster::onEventMsgAttack(serverPos, direction, animId, info); if (info.effectId == 0) { return; } runEffectInfo = info; CCArray *arrayOfActions = CCArray::create(); CCDelayTime * delay = CCDelayTime::create(info.delayTime / 1000); CCCallFunc * func = CCCallFunc::create(this, callfunc_selector(MonsterHaozhu::runByInfo)); arrayOfActions->addObject(delay); arrayOfActions->addObject(func); CCFiniteTimeAction *sequence = CCSequence::create(arrayOfActions); m_rootSprite->stopAllActions(); m_rootSprite->runAction(sequence); }
void LoadingLayer::loadPlist() { m_loadIndex = 0; if (m_plistList) { // 我的加载方法 callBackLoadPlist(); } else if(m_staticYPlist) { // 公用加载方法 loadYAllPng(NULL); } // 没有plist文件 else { m_taxiBus->runAction(CCSequence::create( CCMoveTo::create(0.7, ccp(m_moveLength, m_taxiBus->getPosition().y)), CCCallFunc::create(this, callfunc_selector(LoadingLayer::loadingSuccessful)), NULL)); } }
void Ball::go() { m_curPosIndex++; //当前的位置ID后移 if(m_curPosIndex<m_wayPoint->count()) { CCPoint end=m_wayPoint->getControlPointAtIndex(m_curPosIndex); //速度每秒钟所移动的像素值35 float moveDuration = 0.2f; CCMoveTo *actionMove = CCMoveTo::actionWithDuration(moveDuration,end); CCCallFunc *call=CCCallFunc::actionWithTarget(this,callfunc_selector(Ball::go)); m_goSequneceAction = CCSequence::actions(actionMove,call,NULL); this->m_sprite->runAction(m_goSequneceAction); } else { m_isRemove=true; //超出范围删除 //this->m_sprite->removeFromParentAndCleanup(true); //this->m_balls->removeObject(this); } }