• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ callfunc_selector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中callfunc_selector函数的典型用法代码示例。如果您正苦于以下问题:C++ callfunc_selector函数的具体用法?C++ callfunc_selector怎么用?C++ callfunc_selector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了callfunc_selector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getClosestTarget

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));
	}
}
开发者ID:pototao,项目名称:DefenseTest,代码行数:20,代码来源:Towers.cpp


示例2: GameSlowDown

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);
	}
}
开发者ID:Chonger8888,项目名称:project,代码行数:20,代码来源:GameData.cpp


示例3: runAction

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));
}
开发者ID:terryblood,项目名称:cocos2dx-better,代码行数:22,代码来源:CommonTest.cpp


示例4: callfunc_selector

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;
}
开发者ID:NguyenMinhTri,项目名称:BreakoutCocos2D-x,代码行数:20,代码来源:GameOverScene.cpp


示例5: callfunc_selector

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));
}
开发者ID:jojizaidi,项目名称:Gnome,代码行数:20,代码来源:Player.cpp


示例6: CCLog

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();
}
开发者ID:rick00young,项目名称:HuanHuan,代码行数:41,代码来源:CardSprite.cpp


示例7:

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;
}
开发者ID:jinjianxin,项目名称:cocos2d-x,代码行数:41,代码来源:IntroLayer3.cpp


示例8: animationWithPrefix

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;
}
开发者ID:Iakgun,项目名称:First-Game,代码行数:41,代码来源:HeroSprite.cpp


示例9: addChild

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);
	}
}
开发者ID:rockingdice,项目名称:IceCreamJam,代码行数:41,代码来源:GAMEUI_Scene.cpp


示例10: CCPoint

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;
}
开发者ID:Rogerlin2013,项目名称:CrossApp,代码行数:41,代码来源:CAViewController.cpp


示例11: GET_TYPE

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);
}
开发者ID:jonathanrlin,项目名称:StrangeAdventure,代码行数:48,代码来源:Stage1_6Layer.cpp


示例12: callfunc_selector

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);
}
开发者ID:iichin0708,项目名称:ScrollAndPickUp,代码行数:21,代码来源:HitEffect.cpp


示例13: callfunc_selector

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);
}
开发者ID:DPigpen,项目名称:cocos2dx_recipe,代码行数:21,代码来源:Recipe15.cpp


示例14: addChild

//------------------------------------------------------------------
//
// 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);
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:26,代码来源:ActionManagerTest.cpp


示例15: callfunc_selector

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;
    }
}
开发者ID:Xvionne,项目名称:GAMEDEV_MCO1_Game2,代码行数:21,代码来源:GameOverScene.cpp


示例16: callfunc_selector

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;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:21,代码来源:Explosion.cpp


示例17: ccg

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
        )
    );
}
开发者ID:chaosren,项目名称:HHHH,代码行数:21,代码来源:CCTransition.cpp


示例18: ccp

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;
}
开发者ID:ourgames,项目名称:dc208,代码行数:40,代码来源:PopupViewController.cpp


示例19: sprintf

//受伤动画
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;


}
开发者ID:appleappleapple,项目名称:GameOfFighting,代码行数:41,代码来源:Monster.cpp


示例20: switch

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);
}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:40,代码来源:MonsterHaozhu.cpp



注:本文中的callfunc_selector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ callout_deactivate函数代码示例发布时间:2022-05-30
下一篇:
C++ callfuncO_selector函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap