本文整理汇总了C++中schedule_selector函数的典型用法代码示例。如果您正苦于以下问题:C++ schedule_selector函数的具体用法?C++ schedule_selector怎么用?C++ schedule_selector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了schedule_selector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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++;
}
示例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;
}
示例4: schedule
//------------------------------------------------------------------
//
// SchedulerUpdateFromCustom
//
//------------------------------------------------------------------
void SchedulerUpdateFromCustom::onEnter()
{
SchedulerTestLayer::onEnter();
schedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate), 2.0f);
}
示例5: unschedule
void PlayScene::update(float delta) {
if (sharedDelegate()->CheckRecv()) {
unschedule(schedule_selector(PlayScene::update));
}
}
示例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;
}
示例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);
//.........这里部分代码省略.........
示例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;
}
示例9: scheduleOnce
void AndroidLoad::SetTime(float t)
{
scheduleOnce(schedule_selector(AndroidLoad::ChangeScene) , t);
}
示例10: onEnterTransitionDidFinish
void LoadingScene::onEnterTransitionDidFinish() {
CCScene::onEnterTransitionDidFinish();
this->scheduleOnce(schedule_selector(LoadingScene::loadPublicResource), 0.05);
}
示例11: stop
void LayerGame::stop()
{
this->unschedule(schedule_selector(LayerGame::update));
}
示例12: start
void LayerGame::start()
{
this->schedule(schedule_selector(LayerGame::update), 0.1f);
this->schedule(schedule_selector(LayerGame::addBlock), 3.0f );
}
示例13: scheduleOnce
void PopupLayer::runPublishAnmi()
{
Util::playAudioEffect(MASHANGKAIJIANG, false);
scheduleOnce(schedule_selector( PopupLayer::realRunPublishAnmi),3.0f);
}
示例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;
}
示例15: purgeData
void EnemyInfoController::purgeData() {
CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(EnemyInfoController::onEnterFrame), _instance);
CC_SAFE_RELEASE_NULL( _instance );
_instance = NULL;
}