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

C++ schedule_selector函数代码示例

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

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



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

示例1: CC_CALLBACK_1

void CGameView::onEnter()
{
    Layer::onEnter();
    //----------------------------------------------------
    //FIXME 
    count = 0;
    

    Size visibleSize    = Director::getInstance()->getVisibleSize();
    Vec2 origin         = Director::getInstance()->getVisibleOrigin();

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
        "CloseNormal.png",
        "CloseSelected.png",
        CC_CALLBACK_1(CGameView::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);

    //----------------------------------------------------

    log("CGameView OnEnter...");

    auto lisnter = EventListenerTouchOneByOne::create();

    lisnter->onTouchBegan = CC_CALLBACK_2(CGameView::onTouchBegan, this);
    lisnter->onTouchEnded = CC_CALLBACK_2(CGameView::onTouchEnded, this);
    lisnter->onTouchMoved = CC_CALLBACK_2(CGameView::onTouchMove, this);

    _eventDispatcher->addEventListenerWithSceneGraphPriority(lisnter, this);

    //--------------------------------------------------------------------

    m_pPath             = new CPath();
	m_pDrawNode			= DrawNode::create();    	      	
    m_pSp               = CMySprite::create();
    m_pPlayer           = CGamePlayer::create();
    m_pShowArea         = CShowArea::create();
    m_pGameLogic        = CGameLogic::create();
    
    //------------------------------------

	m_pSp->setPath(m_pPath);
    m_pSp->setPlayer(m_pPlayer);
    m_pSp->setShowArea(m_pShowArea);
    m_pSp->setVisible(false);
          
    m_pShowArea->setPath(m_pPath);
    m_pShowArea->setPosition(origin);


    m_pPlayer->m_refSp              = m_pSp;
    m_pPlayer->setVisible(false);

    m_pGameLogic->m_refPath         = m_pPath;
    m_pGameLogic->m_refPlayer       = m_pPlayer;
    m_pGameLogic->m_refShowArea     = m_pShowArea;
    m_pGameLogic->m_refSp           = m_pSp; 
    m_pGameLogic->setAnchorPoint(Vec2::ZERO);
   
    //----------------------------
		
    addChild(m_pShowArea);	
	addChild(m_pSp);
	addChild(m_pDrawNode);
    addChild(m_pGameLogic);
    addChild(m_pPlayer);

    //------------------------------------    	
	
	m_oAllRander.push_back(m_pSp);
    m_oAllRander.push_back(m_pShowArea);
    m_oAllRander.push_back(m_pPath); 
    m_oAllRander.push_back(m_pPlayer);
    
    //----------------------------------------  

    m_oAllRunner.push_back(m_pSp);
    m_oAllRunner.push_back(m_pPlayer);   
	
    //------------------------------------------ 

    CEventDispatcher::getInstrance()->regsiterEvent(EVENT_WIN, this);
    CEventDispatcher::getInstrance()->regsiterEvent(EVENT_TIMEOUT, this);
    CEventDispatcher::getInstrance()->regsiterEvent(EVENT_PLAYERDIE, this);

    setState(STATE_INIT);                         
	schedule(schedule_selector(CGameView::run));
}
开发者ID:liyan998,项目名称:LineGame,代码行数:95,代码来源:GameView.cpp


示例2: switch

void MainMenuScene::dataLoaded(float percent)
{
	switch (loadingCount)
	{
		case ACTION_RUN:
		{
			CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfoAsync("animations/ChenXiaoGeRunning.ExportJson",this, schedule_selector(MainMenuScene::dataLoaded));
		}
		break;
	
	default:
		{

			CCScene * newscene  = CCScene::create();
			GameScene* gameScene =  GameScene::newGameScene();
			CCTransitionFade* gameSceneTransition =  CCTransitionFade::create(0.5, gameScene, ccWHITE);
			CCDirector::sharedDirector()->replaceScene(gameSceneTransition);
		}
		break;
	}	
	loadingCount++;
}
开发者ID:RaoZiJian,项目名称:ParkourSample,代码行数:22,代码来源:MainMenuScene.cpp


示例3: ccp

//////////////////////////////////////////////////////////////////////////////////////////
//  Creates the context of the game.  Adds background, the score text onto the
// game.
//  Also setups the game scheduling and other handlers.
//////////////////////////////////////////////////////////////////////////////////////////
bool GameScene::init()
{
    if (!CCLayer::init()) {
        return false;
    }

    windowSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    // setup game scheduling/handling/other attributes
    _score = 0;
    _modifier = 1;
    _lastPairMatched = false;
    _pairsMatched = 0;
    this->_gameOver = false;
    this->_lastElapsedTime = GameUtils::getCurrentTime();
    CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(
        "bubble_pop.mp3");
    CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(
        "bubble_pop_2.mp3");
    this->setTouchEnabled(true);

    // add background
    _background = CCSprite::create(BackgroundImage);
    _background->setPosition(
        ccp(windowSize.width / 2 + origin.x, windowSize.height / 2 + origin.y));
    this->addChild(_background, ZIndexBackground);

    // add score label
    char scoreText[25];
    sprintf(scoreText, " %d", _score);
    _scoreLabel = CCLabelTTF::create(scoreText, "Marker Felt.ttf", LABEL_FONT_SIZE);
    _scoreLabel->setColor(GameUtils::getRandomColor3B());
    _scoreLabel->setAnchorPoint(ccp(0, 0));
    _scoreLabel->cocos2d::CCNode::setPosition(
        ccp(LABEL_MARGIN, windowSize.height - topScreenAdjust()));
    this->addChild(_scoreLabel, ZIndexGameTextLabels);

    //add modifier label
    char modifierText[15];
    sprintf(modifierText, "%dx", _modifier);
    _modifierLabel = CCLabelTTF::create(modifierText, "Marker Felt.ttf", LABEL_FONT_SIZE);
    _modifierLabel->setColor(GameUtils::getRandomColor3B());
    _modifierLabel->setAnchorPoint(ccp(0, 0));
    _modifierLabel->cocos2d::CCNode::setPosition(ccp(windowSize.width - _modifierLabel->getContentSize().width - (LABEL_MARGIN * 1.75), windowSize.height - topScreenAdjust()));
    this->addChild(_modifierLabel, ZIndexGameTextLabels);

    // add go image
    _goTextImage = CCMenuItemImage::create("text_go.png", "text_go.png", this, NULL);
    _goTextImage->setPosition(ccp(windowSize.width / 2, windowSize.height / 2));
    this->addChild(_goTextImage, ZIndexGoImage);

    // add initial balls
    _ballArray = *new std::vector<Ball*>();
    for (int i = 0; i < STARTING_BALLS / 2; i++) {
        createNewBalls();
    }

    this->schedule(schedule_selector(GameScene::GameUpdate), 0.01);

    return true;
}
开发者ID:AndrewZurn,项目名称:BubbleBounce-mobile,代码行数:67,代码来源:GameScene.cpp


示例4: schedule

//------------------------------------------------------------------
//
// SchedulerUpdateFromCustom
//
//------------------------------------------------------------------
void SchedulerUpdateFromCustom::onEnter()
{
    SchedulerTestLayer::onEnter();

    schedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate), 2.0f);
}
开发者ID:charlesa101,项目名称:cocos2d-x,代码行数:11,代码来源:SchedulerTest.cpp


示例5: unschedule

void PlayScene::update(float delta) {
  if (sharedDelegate()->CheckRecv()) {
    unschedule(schedule_selector(PlayScene::update));
  }
}
开发者ID:f17qh,项目名称:crazyass,代码行数:5,代码来源:play_scene.cpp


示例6: menu_selector


//.........这里部分代码省略.........
	////Button Exit
	{
		CCMenuItemImage *pExitButton = CCMenuItemImage::create(
			"MainMenuScene\\exit1.png",
			"MainMenuScene\\exit2.png",
			this,
			menu_selector(CMainMenuScene::menuCloseCallback));
		pExitButton->setPosition(LOCATION_BUTTON_EXIT);
		m_pMenu->addChild(pExitButton);
	}
	
	//BUtton About
	{
		CCMenuItemImage *pAboutButton = CCMenuItemImage::create(
			"MainMenuScene\\about1.png",
			"MainMenuScene\\about2.png",
			this,
			menu_selector(CMainMenuScene::menuAboutCallback));
		pAboutButton->setPosition(LOCATION_BUTTON_ABOUT);
		m_pMenu->addChild(pAboutButton);
	}

	//Button Option
	{
		CCMenuItemImage *pOptionsButton = CCMenuItemImage::create(
			"MainMenuScene\\option1.png",
			"MainMenuScene\\option2.png",
			this,
			menu_selector(CMainMenuScene::menuOptionsCallback));
		pOptionsButton->setPosition(LOCATION_BUTTON_OPTION);
		m_pMenu->addChild(pOptionsButton);
	}

	//Button Help
	{
		CCMenuItemImage *pHelpButton = CCMenuItemImage::create(
			"MainMenuScene\\help1.png",
			"MainMenuScene\\help2.png",
			this,
			menu_selector(CMainMenuScene::menuHelpCallback));
		pHelpButton->setPosition(LOCATION_BUTTON_HELP);
		m_pMenu->addChild(pHelpButton);
	}
	
	this->addChild(m_pMenu, 1);



	//Background
	CCSprite* pSprite = CCSprite::create("MainMenuScene\\protectlane.png");
	pSprite->setPosition( ccp(size.width/2, size.height/2) );
	this->addChild(pSprite, 0);

	//Animation Fire
	CMySprite* pAnimFire=new CMySprite("Tower\\tower.sprite");
	pAnimFire->setPosition(LOCATION_ANIM_FIRE);
	pAnimFire->setScale(1.5f);
	this->addChild(pAnimFire);
	pAnimFire->PlayAnimation(FIRE_TOWER, 0.4f, true, false);


	/************************************************************************/
	/* Pop up Menu                                                          */
	/************************************************************************/
	CCMenuItemImage *pYesItem = CCMenuItemImage::create(
		"Button\\yes-down.png",
		"Button\\yes-up.png",
		this,
		menu_selector(CMainMenuScene::PopupYesCallback));
	//pYesItem->setPosition(size.width/2.0f + 100.0f, size.height/2.0f);
	pYesItem->setPosition(220.0f, 0.0f);
	CCMenuItemImage *pNoItem = CCMenuItemImage::create(
		"Button\\no-down.png",
		"Button\\no-up.png",
		this,
		menu_selector(CMainMenuScene::PopupNoCallback));
	//pNoItem->setPosition(size.width/2.0f + 150.0f, size.height/2.0f);
	pNoItem->setPosition(380.0f, 0.0f);
	m_pBlurLayer = CCLayerColor::create();
	m_pBlurLayer->setOpacityModifyRGB(true);
	m_pBlurLayer->setColor(ccc3(0,0,0));
	m_pBlurLayer->setOpacity(150);
	this->addChild(m_pBlurLayer, ZORDER_GAMEPLAY_COLOR_LAYER, TAG_GAMEPLAY_COLOR_LAYER);
	
	//set position of Popup
	pPopupBackground = CCSprite::create("Button\\popup1.png");
	pPopupBackground->setPosition(ccp( size.width/2, size.height/2 ));	
	this->addChild(pPopupBackground,ZORDER_GAMEPLAY_COLOR_LAYER + 1, TAG_GAMEPLAY_COLOR_LAYER + 1);

	m_pPopupMenu = CCMenu::create(pYesItem, NULL);
	m_pPopupMenu->addChild(pNoItem);	
	this->addChild(m_pPopupMenu,ZORDER_GAMEPLAY_COLOR_LAYER + 1, TAG_GAMEPLAY_COLOR_LAYER + 1);

	EnablePopupMenu(false);

	schedule(schedule_selector(CMainMenuScene::update));
	CCDirector::sharedDirector()->getTouchDispatcher()->removeAllDelegates();
	setTouchEnabled(false);
	return true;
}
开发者ID:chiehfc,项目名称:protect-land,代码行数:101,代码来源:MainMenuScene.cpp


示例7: CC_RETURN_IF

void CATouchController::touchMoved()
{
    CC_RETURN_IF(ccpDistance(m_tFirstPoint, m_pTouch->getLocation()) < _px(32));
    
    m_tFirstPoint = CCPointZero;
    
    if (!m_vTouchMovedsViewCache.empty())
    {
        bool isScheduledPassing = CAScheduler::isScheduled(schedule_selector(CATouchController::passingTouchesViews), this);
        
        CAScheduler::unschedule(schedule_selector(CATouchController::passingTouchesViews), this);
        
        while (!m_vTouchMovedsViewCache.empty())
        {
            CAResponder* responder = m_vTouchMovedsViewCache.back();
            CCPoint pointOffSet = CCPointZero;
            if (CAView* v = dynamic_cast<CAView*>(responder))
            {
                pointOffSet = ccpSub(v->convertToNodeSpace(m_pTouch->getLocation()),
                                     v->convertToNodeSpace(m_pTouch->getPreviousLocation()));
            }
            else if (CAViewController* c = dynamic_cast<CAViewController*>(responder))
            {
                pointOffSet = ccpSub(c->getView()->convertToNodeSpace(m_pTouch->getLocation()),
                                     c->getView()->convertToNodeSpace(m_pTouch->getPreviousLocation()));
            }
            else
            {
                pointOffSet = ccpSub(m_pTouch->getLocation(), m_pTouch->getPreviousLocation());
            }
            
            pointOffSet.x = fabsf(pointOffSet.x);
            pointOffSet.y = fabsf(pointOffSet.y);
            
            do
            {
                CC_BREAK_IF(!responder->isTouchMovedListenHorizontal() && pointOffSet.x >= pointOffSet.y);
                CC_BREAK_IF(!responder->isTouchMovedListenVertical() && pointOffSet.x < pointOffSet.y);
                m_vTouchMovedsView.pushBack(m_vTouchMovedsViewCache.back());
            }
            while (0);
            
            m_vTouchMovedsViewCache.popBack();
        }
        
        
        CAVector<CAResponder * > tTouchesViews = m_vTouchesViews;
        if (!m_vTouchMovedsView.empty())
        {
            if (!isScheduledPassing)
            {
                
                CAVector<CAResponder*>::iterator itr;
                //
                for (itr = m_vTouchMovedsView.begin(); itr != m_vTouchMovedsView.end(); itr++)
                {
                    m_vTouchesViews.eraseObject(*itr, true);
                }
                //
                
                for (itr=m_vTouchesViews.begin(); itr!=m_vTouchesViews.end(); itr++)
                {
                    (*itr)->ccTouchCancelled(m_pTouch, m_pEvent);
                }
            }
            
            {
                m_vTouchesViews.clear();
                
                for (int i=0; i<m_vTouchMovedsView.size(); i++)
                {
                    CAResponder* responder = m_vTouchMovedsView.at(i);
                    CCPoint pointOffSet = CCPointZero;
                    if (CAView* v = dynamic_cast<CAView*>(responder))
                    {
                        pointOffSet = ccpSub(v->convertToNodeSpace(m_pTouch->getLocation()),
                                             v->convertToNodeSpace(m_pTouch->getPreviousLocation()));
                    }
                    else if (CAViewController* c = dynamic_cast<CAViewController*>(responder))
                    {
                        pointOffSet = ccpSub(c->getView()->convertToNodeSpace(m_pTouch->getLocation()),
                                             c->getView()->convertToNodeSpace(m_pTouch->getPreviousLocation()));
                    }
                    else
                    {
                        pointOffSet = ccpSub(m_pTouch->getLocation(), m_pTouch->getPreviousLocation());
                    }
                    
                    if (responder->isTouchMovedListenHorizontal()
                        && fabsf(pointOffSet.x) >= fabsf(pointOffSet.y))
                    {
                        CC_CONTINUE_IF(responder->isSlidingMinX() && pointOffSet.x > 0);
                        CC_CONTINUE_IF(responder->isSlidingMaxX() && pointOffSet.x < 0);
                    }
                    
                    if (responder->isTouchMovedListenVertical()
                        && fabsf(pointOffSet.x) < fabsf(pointOffSet.y))
                    {
                        CC_CONTINUE_IF(responder->isSlidingMinY() && pointOffSet.y > 0);
                        CC_CONTINUE_IF(responder->isSlidingMaxY() && pointOffSet.y < 0);
//.........这里部分代码省略.........
开发者ID:zhaojietong,项目名称:CrossApp,代码行数:101,代码来源:CATouchDispatcher.cpp


示例8: CC_CALLBACK_1

bool GamePlayScene::init() {

	if (!LayerColor::initWithColor(Color4B(0, 255, 255, 255))) {
		return false;
	}

	this->setKeypadEnabled(true);


	_holdBack = Sprite::create("commons/images/holdback.png");
	_holdBack->setPosition(Vec2(240, 400));
	this->addChild(_holdBack, 0);

	_slideBack = Sprite::create("commons/images/slideback.png");
	_slideBack->setAnchorPoint(Vec2(0.5, 0.0));
	_slideBack->setPosition(Vec2(240, 0));
	this->addChild(_slideBack, 1);




	_stageButton = MenuItemImage::create(
		"playscene/images/stage.png",
		"playscene/images/stageclicked.png",
		CC_CALLBACK_1(GamePlayScene::menuCloseCallback, this));
	_stageButton->setAnchorPoint(Vec2(0.5, 0.5));
	_stageButton->setPosition(Vec2(-190, 360));
	_stageButton->setTag(1);


	_homeButton = MenuItemImage::create(
		"playscene/images/home.png",
		"playscene/images/homeclicked.png",
		CC_CALLBACK_1(GamePlayScene::menuCloseCallback, this));
	_homeButton->setAnchorPoint(Vec2(0.5, 0.5));
	_homeButton->setPosition(Vec2(-130, 360));
	_homeButton->setTag(2);

	_muteButton = MenuItemImage::create(
		"playscene/images/sound.png",
		"playscene/images/sound.png",
		CC_CALLBACK_1(GamePlayScene::menuCloseCallback, this));
	_muteButton->setAnchorPoint(Vec2(0.5, 0.5));
	_muteButton->setPosition(Vec2(200, 360));
	_muteButton->setTag(3);


	_resetButton = MenuItemImage::create(
		"playscene/images/return.png",
		"playscene/images/returnclicked.png",
		CC_CALLBACK_1(GamePlayScene::menuCloseCallback, this));
	_resetButton->setAnchorPoint(Vec2(0.5, 0.5));
	_resetButton->setPosition(Vec2(0, -360));
	_resetButton->setTag(4);

	auto menu = Menu::create(_stageButton, _homeButton, _muteButton, _resetButton,NULL);

	menu->setPosition(Vec2(240, 400));

	this->addChild(menu, 3);

	layer_top = MapLayer::create();
	layer_top->setPosition(Vec2(40, 200));
	layer_top->setContentSize(Size(400, 400));
	layer_top->retain();
	this->addChild(layer_top, 2);


	this->schedule(schedule_selector(GamePlayScene::backgroundSlideSchedule), 20.0f, CC_REPEAT_FOREVER, 20.0f);

	return true;
}
开发者ID:tooOpen,项目名称:Thinking-snake-game,代码行数:72,代码来源:GamePlayScene.cpp


示例9: scheduleOnce

void AndroidLoad::SetTime(float t)
{
    scheduleOnce(schedule_selector(AndroidLoad::ChangeScene) , t);
}
开发者ID:CooloiStudio,项目名称:Cocos2d-x_oHitx,代码行数:4,代码来源:AndroidLoadScene.cpp


示例10: onEnterTransitionDidFinish

void LoadingScene::onEnterTransitionDidFinish() {
    CCScene::onEnterTransitionDidFinish();
    this->scheduleOnce(schedule_selector(LoadingScene::loadPublicResource), 0.05);
}
开发者ID:itita,项目名称:2-z-q-x-,代码行数:4,代码来源:LoadingScene.cpp


示例11: stop

void LayerGame::stop()
{
    this->unschedule(schedule_selector(LayerGame::update));
}
开发者ID:yitianljt,项目名称:ShareTest_git,代码行数:4,代码来源:LayerGame.cpp


示例12: start

void LayerGame::start()
{
    this->schedule(schedule_selector(LayerGame::update), 0.1f);
    this->schedule(schedule_selector(LayerGame::addBlock), 3.0f );
}
开发者ID:yitianljt,项目名称:ShareTest_git,代码行数:5,代码来源:LayerGame.cpp


示例13: scheduleOnce

void PopupLayer::runPublishAnmi()
{
	Util::playAudioEffect(MASHANGKAIJIANG, false);
	scheduleOnce(schedule_selector( PopupLayer::realRunPublishAnmi),3.0f);
}
开发者ID:coolshou,项目名称:richer,代码行数:5,代码来源:PopupLayer.cpp


示例14: ccp

bool GameLayer::init() {
	if (!CCLayer::init()) {
		return false;
	}

	//if(self=[super init]){
	this->setTouchEnabled(true);

	//this->initObjects();
	enemies = CCArray::create();
	enemies->retain();
	bullets = CCArray::create();
	bullets->retain();
	props = CCArray::create();
	props->retain();

	superBullet = false;
	bombCount = 0;
	score = 0;
	//this->getWinsize();
	winSize = CCDirector::sharedDirector()->getWinSize();
	//资源加载
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("gameArts.plist");
	//CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::create("gameArts.png");
	//背景控制
	backgroundSprite_1 = CCSprite::create("background_2.png");
	backgroundSprite_2 = CCSprite::create("background_2.png");
	//减去2px可以让两个背景块有细微重叠,会看到两个背景块中间的细缝.
	backgroundHeight = backgroundSprite_1->boundingBox().size.height - 3;

	backgroundSprite_1->setAnchorPoint(ccp(0.5f, 0));
	backgroundSprite_2->setAnchorPoint(ccp(0.5f, 0));

	backgroundSprite_1->setPosition(ccp(winSize.width/2, 0));
	backgroundSprite_2->setPosition(ccp(winSize.width/2, backgroundHeight));

	this->addChild(backgroundSprite_1, 0);
	this->addChild(backgroundSprite_2, 0);
	//this->loadBackgroundSprites();
	//this->startBackgroundMoving();
	this->moveBackgroundDownWithSprite(backgroundSprite_1);
	this->moveBackgroundDownWithSprite(backgroundSprite_2);

	//玩家飞机的生成和控制
	playerPlane = CCSprite::create("hero_fly_1.png");
	playerPlane->setPosition(ccp(winSize.width/2, 0.2*winSize.height));
	this->addChild(playerPlane, 3);
	//this->setTouchEnabled(true);

	CCAction * planeAction = this->frameAnimationWithFrameName("hero_fly_%i.png", 2, 0.2f, 0);
	playerPlane->runAction(planeAction);
	CCNode::onEnter();
	//子弹生成和控制
	this->schedule(schedule_selector(GameLayer::shootBullet), 0.2f);
	//if(1)return true;
	//敌机生成和控制
	this->schedule(schedule_selector(GameLayer::showEnemy), 0.8f);
	//if(1)return true;
	//碰撞检测
	this->schedule(schedule_selector(GameLayer::checkingCollision));

	bomb = CCSprite::create("bomb.png");
	bomb->setAnchorPoint( ccp(0, 0));
	bomb->setPosition( ccp(winSize.width*0.05, winSize.width*0.05));
	this->addChild(bomb);
	bomb->setVisible(false);

	//道具生成和控制
	this->schedule(schedule_selector(GameLayer::showProp), 20.0f);
	//分数标签
	scoreLabel = CCLabelTTF::create("Score:0", "MarkerFelt-Thin",
			winSize.height * 0.0625);
	scoreLabel->setColor(ccc3(0, 0, 0));
	scoreLabel->setAnchorPoint(ccp(0, 1));
	scoreLabel->setPosition(ccp(0, winSize.height));
	this->addChild(scoreLabel);
	//}
	return true;
}
开发者ID:humphery755,项目名称:cocos2d-x,代码行数:79,代码来源:GameLayer.cpp


示例15: purgeData

void EnemyInfoController::purgeData() {
    CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(EnemyInfoController::onEnterFrame), _instance);
    CC_SAFE_RELEASE_NULL( _instance );
    _instance = NULL;
}
开发者ID:ourgames,项目名称:dc208,代码行数:5,代码来源:EnemyInfoController.cpp


示例16: addChild

bool GameLayer::init(){
	if(Layer::init()) {
		//get the origin point of the X-Y axis, and the visiable size of the screen
		Size visiableSize = Director::getInstance()->getVisibleSize();
		Point origin = Director::getInstance()->getVisibleOrigin();

		this->gameStatus = GAME_STATUS_READY;
		this->score = 0;

		// Add the bird
		this->bird = BirdSprite::getInstance();
		this->bird->createBird();
		PhysicsBody *body = PhysicsBody::create();
        body->addShape(PhysicsShapeCircle::create(BIRD_RADIUS));
        body->setCategoryBitmask(ColliderTypeBird);
        body->setCollisionBitmask(ColliderTypeLand & ColliderTypePip | ColliderTypeBall);
        body->setContactTestBitmask(ColliderTypeLand | ColliderTypePip | ColliderTypeBall);
        body->setDynamic(true);
		body->setLinearDamping(0.0f);
		body->setGravityEnable(false);
		this->bird->setPhysicsBody(body);
		this->bird->setPosition(origin.x + visiableSize.width*1/3 - 5,origin.y + visiableSize.height/2 + 5);
		this->bird->idle();
		this->addChild(this->bird);
		//Ball
		this->ball = Sprite::create("Ball.png");
        PhysicsBody *ballbody = PhysicsBody::create();
        ballbody->addShape(PhysicsShapeCircle::create(BIRD_RADIUS+5));
		
		
        ballbody->setCategoryBitmask(ColliderTypeBall);
        ballbody->setCollisionBitmask(ColliderTypePip | ColliderTypeLand);
        ballbody->setContactTestBitmask(ColliderTypePip | ColliderTypeLand);
		

        ballbody->setDynamic(true);
		ballbody->setLinearDamping(0.0f);
		ballbody->setGravityEnable(false);
		ball->setPhysicsBody(ballbody);
		ball->setPosition(bird->getPositionX(),bird->getPositionY()+30);
		ball->setTag(100);
		addChild(ball);

		BallisTouch = false;

		//BallName
//		ballName = Sprite::create("BallWithHoney.png");
        ballName = Sprite::create("star.png");

		ballName->setPosition(ball->getPositionX(),ball->getPositionY()+40);
		//addChild(ballName);

        // Add the ground
        this->groundNode = Node::create();
        float landHeight = BackgroundLayer::getLandHeight();
        auto groundBody = PhysicsBody::create();
        groundBody->addShape(PhysicsShapeBox::create(Size(288, landHeight)));
        groundBody->setDynamic(false);
        groundBody->setLinearDamping(0.0f);
        groundBody->setCategoryBitmask(ColliderTypeLand);
        groundBody->setCollisionBitmask(ColliderTypeBird | ColliderTypeBall);
        groundBody->setContactTestBitmask(ColliderTypeBird | ColliderTypeLand);
        this->groundNode->setPhysicsBody(groundBody);
        this->groundNode->setPosition(144, landHeight/2);
        this->addChild(this->groundNode);
        
        // init land
        this->landSpite1 = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("land"));
        this->landSpite1->setAnchorPoint(Point::ZERO);
        this->landSpite1->setPosition(Point::ZERO);
        this->addChild(this->landSpite1, 30);
        
        this->landSpite2 = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("land"));
        this->landSpite2->setAnchorPoint(Point::ZERO);
        this->landSpite2->setPosition(this->landSpite1->getContentSize().width-2.0f,0);
        this->addChild(this->landSpite2, 30);
        
		shiftLand = schedule_selector(GameLayer::scrollLand);
        this->schedule(shiftLand, 0.01f);
        
        this->scheduleUpdate();

		auto contactListener = EventListenerPhysicsContact::create();
		contactListener->onContactBegin = CC_CALLBACK_1(GameLayer::onContactBegin, this);
		this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(contactListener, this);
		
		return true;
	}else {
		return false;
	}
}
开发者ID:HotWordland,项目名称:Earlybird,代码行数:91,代码来源:GameLayer.cpp


示例17: Fire

void EvilQueenBlade::Fire(){
    this->scheduleOnce(schedule_selector(EvilQueenBlade::RealFire), 1.0f*option);
}
开发者ID:gnosy1590,项目名称:projectWhipping,代码行数:3,代码来源:EvilQueenBlade.cpp


示例18: CC_BREAK_IF


//.........这里部分代码省略.........
			CC_BREAK_IF(pBtnCommon==NULL);
			pBtnCommon->setPosition(ccp(SCREEN_WIDTH - 60,58));
			pMenu->addChild(pBtnCommon,enZOrderFront,enTagBtnCommonAttack);



			CCLabelBMFont* pCommonAttackFont = CCLabelBMFont::create("1","fonts/mhp_num.fnt");
			pCommonAttackFont->setPosition(pBtnCommon->getPosition());
			this->addChild(pCommonAttackFont,enZOrderFront,enTagCommonAttackFont);

			CCSprite * pCommon3 = CCSprite::create("gameui/skill_common.png");
			CC_BREAK_IF(pCommon3==NULL);
			pCommon3->setColor(ccRED);
			pCommon3->setOpacity(100.f);
			
			//创建普通攻击CD
			CCProgressTimer* pProgressCommonAttackCD = CCProgressTimer::create(pCommon3);
			CC_BREAK_IF(pProgressCommonAttackCD==NULL);
			pProgressCommonAttackCD->setType(kCCProgressTimerTypeRadial);
			pProgressCommonAttackCD->setMidpoint(ccp(0.5f,0.5f));
			pProgressCommonAttackCD->setPercentage(0.f);
			pProgressCommonAttackCD->setPosition(pBtnCommon->getPosition());
			this->addChild(pProgressCommonAttackCD,enZOrderFront+1,enTagCommonAttackCD);

			//创建技能按钮
			for (int i=enTagBtnSkill1;i<=enTagBtnSkill5;i++)
			{
				char szName[NAME_LEN] = {0};

				int skilltemp = -1;
				if(i==enTagBtnSkill1){
					skilltemp = m_nSkill_1_ID;
				}else if(i==enTagBtnSkill2){
					skilltemp = m_nSkill_2_ID;
				}else if(i==enTagBtnSkill3){
					skilltemp = m_nSkill_3_ID;
				}else if(i==enTagBtnSkill4){
					skilltemp = m_nSkill_4_ID;
				}else if(i==enTagBtnSkill5){
					skilltemp = m_nSkill_5_ID;
				}

				if(skilltemp==-1){
					continue;
				}

				sprintf(szName,"Skill/r%d_s%d.png",pPro->GetRoleID(),skilltemp);

				CCSprite * pSpr_n = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_n==NULL);
				CCSprite * pSpr_p = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_p==NULL);;
				pSpr_p->setColor(ccBLUE);
				CCSprite * pSpr_d = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_d==NULL);
				pSpr_d->setOpacity(150.f);
				CCSprite * pSpr_CD = CCSprite::create(szName);
				CC_BREAK_IF(pSpr_CD==NULL);
				pSpr_CD->setColor(ccRED);

				//创建技能按钮
				CCMenuItemSprite * pBtn = CCMenuItemSprite::create(pSpr_n,pSpr_p,pSpr_d,this,menu_selector(CNFRockerLayer::OnBtnCallBack));
				CC_BREAK_IF(pBtn==NULL);
				pMenu->addChild(pBtn,enZOrderFront,i);
				if(i==enTagBtnSkill1)		pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+90));
				else if(i==enTagBtnSkill2)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-110,pBtnCommon->getPositionY()-5));
				else if(i==enTagBtnSkill3)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-70,pBtnCommon->getPositionY()+70));
				else if(i==enTagBtnSkill4)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()-200,pBtnCommon->getPositionY()-5));
				else if(i==enTagBtnSkill5)	pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+170));

				//创建技能CD
				CCProgressTimer* pProgress = CCProgressTimer::create(pSpr_p);
				CC_BREAK_IF(pProgress==NULL);
				pProgress->setType(kCCProgressTimerTypeRadial);
				pProgress->setMidpoint(ccp(0.5f,0.5f));
				pProgress->setPercentage(0.f);
				pProgress->setPosition(pBtn->getPosition());
				this->addChild(pProgress,enZOrderFront+1,i+100);		//技能CD标签 = 技能标签 + 100

				//创建公共CD
				CCProgressTimer* pProgressCD = CCProgressTimer::create(pSpr_CD);
				CC_BREAK_IF(pProgressCD==NULL);
				pProgressCD->setType(kCCProgressTimerTypeRadial);
				pProgressCD->setMidpoint(ccp(0.5f,0.5f));
				pProgressCD->setPercentage(0.f);
				pProgressCD->setPosition(pBtn->getPosition());
				this->addChild(pProgressCD,enZOrderFront+2,i+200);		//技能CD标签 = 技能标签 + 200
				pProgressCD->setVisible(false);
			}
		}
		

		//更新函数
		schedule(schedule_selector(CNFRockerLayer::update));

		return true;
	} while (false);
	CCLog("Fun CNFRockerLayer::InitLayer Error!");
	return false;
}
开发者ID:baidang201,项目名称:NarutoFight,代码行数:101,代码来源:NFRocker.cpp


示例19: setScope

bool AntiVisibleTower::init()
{
	if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错
	{
		return false;
	}
	
	instance = GameManager::getInstance();   

	setScope(300);
	setAttack(0);
	setRate(5);//4秒钟开火一次
	setTowerType(3);
	setIsSelected(false);
	setGrade(0);//开始没有等级
	setPower(40);//塔消耗电力
	setMove(false);//开始不处于移动状态
	setIsPowerEnough(true);//开始状态电力足够
	setIsPowerConsumption(true);//该塔耗电
	nearestEnemy = nullptr;

	towerSprite = Sprite::create("towerItem/Item99.png");
	addChild(towerSprite, 5);

	gradeSprite = Sprite::create("level1.png");
	gradeSprite->setAnchorPoint(Point(0, 0));
	gradeSprite->setPosition(this->getPosition().x + 10, -towerSprite->getBoundingBox().size.height / 2);
	gradeSprite->setOpacity(0);//开始让其不可见
	addChild(gradeSprite, 6);

	noPowerSprite = Sprite::create("noPower.png");
	noPowerSprite->setAnchorPoint(Point(0.5, 0));
	noPowerSprite->setScale(1.4);
	noPowerSprite->setPosition(towerSprite->getBoundingBox().size.width / 2 - 70, towerSprite->getBoundingBox().size.height - 40);
	noPowerSprite->setVisible(false);
	addChild(noPowerSprite, 7);

	//血量条背景图片
	towerHpSprite = Sprite::create("manaBarBg.png");
	towerHpSprite->setPosition(noPowerSprite->getPosition()-Point(0,25));
	towerHpSprite->setScale(0.8);
	addChild(towerHpSprite, 10);
	//炮塔血量
	hp = 4;
	//炮塔血量进度条
	towerHp = ProgressTimer::create(Sprite::create("soldierProduceTimeBar.png")); //参数是一个图片sprite
	towerHp->setScaleX(2);
	towerHp->setScaleY(5.2);
	towerHp->setType(ProgressTimer::Type::BAR);
	towerHp->setMidpoint(Point(0, 0.5f));
	towerHp->setBarChangeRate(Point(1, 0));
	towerHp->setPercentage(100);
	towerHp->setPosition(Point(towerHpSprite->getContentSize().width / 2, towerHpSprite->getContentSize().height / 3 * 2 - 10));
	towerHpSprite->addChild(towerHp, 5);
	//初始化不可见
	towerHp->setVisible(false);
	towerHpSprite->setVisible(false);

	schedule(schedule_selector(AntiVisibleTower::shoot), 0.1f);
	schedule(schedule_selector(AntiVisibleTower::checkNearestEnemy, this), 0.2);
	addTouch();//添加触摸事件 

	return true;
}
开发者ID:houzisbw,项目名称:Cocos2dx_TowerDefense_Version2,代码行数:64,代码来源:AntiVisibleTower.cpp


示例20: CC_BREAK_IF

// on "init" you need to initialize your instance
bool MainScene::init()
{
	bool bRet = false;
	do 
	{
		//////////////////////////////////////////////////////////////////////////
		// super init first
		//////////////////////////////////////////////////////////////////////////

		CC_BREAK_IF(! CCLayer::init());

		//////////////////////////////////////////////////////////////////////////
		// add your codes below...
		//////////////////////////////////////////////////////////////////////////

		// 1. Add a menu item with "X" image, which is clicked to quit the program.

		// Create a "close" menu item with close icon, it's an auto release object.
/*		CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
			"CloseNormal.png",
			"CloseSelected.png",
			this,
			menu_selector(GameScene::menuCloseCallback));
		CC_BREAK_IF(! pCloseItem);

		// Place the menu item bottom-right conner.
		pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));

		// Create a menu with the "close" menu item, it's an auto release object.
		CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
		pMenu->setPosition(CCPointZero);
		CC_BREAK_IF(! pMenu);

		// Add the menu to HelloWorld layer as a child layer.
		this->addChild(pMenu, 1);
*/
		// 2. Add a label shows "Hello World".

		// Create a label and initialize with string "Hello World".
/*		CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
		CC_BREAK_IF(! pLabel);

		// Get window size and place the label upper. 
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		pLabel->setPosition(ccp(size.width / 2, size.height - 50));

		// Add the label to HelloWorld layer as a child layer.
		this->addChild(pLabel, 1);
*/
		// 3. Add add a splash screen, show the cocos2d splash image.

		size = CCDirector::sharedDirector()->getWinSize();

		CCSprite* pSprite = CCSprite::create("images/background.png");
		CC_BREAK_IF(! pSprite);

		// Place the sprite on the center of the screen
		pSprite->setPosition(ccp(size.width/2, size.height/2));

		// Add the sprite to HelloWorld layer as a child layer.
		this->addChild(pSprite, 0);
		
		CCMenuItemFont* itemPlay = CCMenuItemFont::create("Play", this, menu_selector(MainScene::menuPlayCallback));
		CCMenuItemFont* itemOptions = CCMenuItemFont::create("Options", this, menu_selector(MainScene::menuOptionsCallback));
		CCMenuItemFont* itemScores = CCMenuItemFont::create("Scores", this, menu_selector(MainScene::menuScoresCallback));
		CCMenuItemFont* itemAbout = CCMenuItemFont::create("About", this, menu_selector(MainScene::menuAboutCallback));
		CCMenuItemFont* itemQuit = CCMenuItemFont::create("Quit", this, menu_selector(MainScene::menuCloseCallback));
		CCMenu* menu = CCMenu::create(itemPlay, itemOptions, itemScores, itemAbout, itemQuit, NULL);
		menu->alignItemsVerticallyWithPadding(20);
		this->addChild(menu, 1);

		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(
			"images/images.plist",
			"images/images.png");
		CCTexture2D* texture = CCTextureCache::sharedTextureCache()->textureForKey("images/images.png");
		node = CCSpriteBatchNode::createWithTexture(texture);
		this->addChild(node);

		this->schedule(schedule_selector(MainScene::update), 0.1f);

		bRet = true;
	} while (0);

	return bRet;
}
开发者ID:hotdl,项目名称:hotdl,代码行数:86,代码来源:MainScene.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ schedule_task函数代码示例发布时间:2022-05-30
下一篇:
C++ schedule_hrtimeout_range函数代码示例发布时间: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