本文整理汇总了C++中scheduleOnce函数的典型用法代码示例。如果您正苦于以下问题:C++ scheduleOnce函数的具体用法?C++ scheduleOnce怎么用?C++ scheduleOnce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scheduleOnce函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scheduleOnce
COLL_RET TankAILife3::onCollision(cocos2d::Node* other)
{
if (other->getTag() == COLL_BULLET || other->getTag() == COLL_BULLET_IRON)
{
if (3 == _life)
{
_twoLifeSprite = Sprite::createWithSpriteFrameName("tank_life3_2.png");
_twoLifeSprite->setScale(_scale);
this->setTexture(_twoLifeSprite->getTexture());
this->addChild(_twoLifeSprite);
--_life;
if (!_isSleeping)
{
scheduleOnce(schedule_selector(TankAILife3::resumeLife), 3.0f);
}
return RETAIN;
}else if (2 == _life)
{
_oneLifeSprite = Sprite::createWithSpriteFrameName("tank_life3_1.png");
_oneLifeSprite->setScale(_scale);
this->setTexture(_oneLifeSprite->getTexture());
this->addChild(_oneLifeSprite);
--_life;
if (!_isSleeping)
{
scheduleOnce(schedule_selector(TankAILife3::resumeLife2), 3.0f);
}
return RETAIN;
}
}
return TankAI::onCollision(other);
}
示例2: scheduleOnce
void HelloWorld::ScoreSchedule(float dt)
{
//ShowNumberNode * snn = ShowNumberNode::CreateShowNumberNode("menu_num_white.png", 923, 9/mfac, 18/mfac );
//float xpos=m_pScore->boundingBox().getMaxX()-m_pScore->boundingBox().getMinX()-45;
//float ypos=m_pScore->boundingBox().getMaxY()-m_pScore->boundingBox().getMinY()-45;
if (++myscore<= testnum)
{
msnn->f_ShowNumber(myscore);
}
else
{
scheduleOnce(schedule_selector(HelloWorld::MoveStart), 0.5);
scheduleOnce(schedule_selector(HelloWorld::MoveTop), 0.5);
unschedule(schedule_selector(HelloWorld::ScoreSchedule));
scheduleOnce(schedule_selector(HelloWorld::addShare), 1);
//m_pStart->setVisible(true);
//m_pTop->setVisible(true);
}
//snn->setPosition(ccp(xpos,ypos));
//m_pScore->addChild(snn,5,0);
//schedule(schedule_selector(HelloWorld::logic), 2.0f);
}
示例3: removeChild
void Battle::playActionOver(cocostudio::Armature *armature, cocostudio::MovementEventType type, const char *name) {
if (armature == m_pReadygo) {
if (type == COMPLETE) {
removeChild(armature);
m_pReadygo = NULL;
unmask();
BIND(BUND_ID_GLOBAL_TOUCH_MOVED, this, Battle::globalTouchMoved);
g_pEventEngine->BundlerCall(BUND_ID_PLANE_FIRE, this, sizeof(this));
}
}
if (armature == m_pBossIn) {
if (type == COMPLETE) {
removeChild(armature);
m_pBossIn = NULL;
unmask();
const BossConfig * pconfig = g_pGameConfig->getBossConfig(m_pConfig->boss);
m_pBoss = Boss::create(pconfig);
addChild(m_pBoss, GRADE_ENEMY);
if (m_pConfig->boss != "chisezhilang") {
m_pBoss->setScale(g_pGameConfig->scaleEleMin);
} else {
m_pBoss->setScale(g_pGameConfig->scaleEleMin * 1.5);
}
m_pBoss->setPosition(Vec2(pconfig->pos.x * g_pGameConfig->scaleEleX, pconfig->pos.y * g_pGameConfig->scaleEleY));
m_pBoss->setRotation(pconfig->rotate);
ActionInterval * action = MoveBy::create(2, Vec2(0, -500 * g_pGameConfig->scaleEleY));
m_pBoss->runAction(Sequence::create(action, CallFuncN::create(this, callfuncN_selector(Battle::playbossAi)), NULL));
}
}
if (armature == m_pMissionVictory) {
if (type == COMPLETE) {
Node * icon = g_pGameConfig->getIcon(m_equip.model, m_equip.type);
icon->setPosition(Vec2(-200, -275));
icon->setScale(g_pGameConfig->scaleEleMin * 5);
m_pMissionVictory->addChild(icon, GRADE_UI);
icon->setOpacity(0);
ActionInterval * scale = ScaleTo::create(.5f, g_pGameConfig->scaleEleMin * 1.5);
ActionInterval * fadein = FadeIn::create(.5f);
icon->runAction(Spawn::create(scale, fadein, NULL));
UNBIND(BUND_ID_GLOBAL_TOUCH_MOVED, this, Battle::globalTouchMoved);
scheduleOnce(schedule_selector(Battle::returnMission), 2.0f);
}
}
if (armature == m_pMissionFaild) {
if (type == COMPLETE) {
UNBIND(BUND_ID_GLOBAL_TOUCH_MOVED, this, Battle::globalTouchMoved);
scheduleOnce(schedule_selector(Battle::returnMission), 2.0f);
}
}
}
示例4: switch
void Battle::OnHttpRes(const s32 id, const Json::Value * root, const void * context, const s32 size) {
switch (id) {
case HTTP_REQUEST_ID_COUNT_PVE:
{
if (NULL == root) {
ALERT("请检查你的网络连接");
return;
}
if ((*root)["code"] == ERROR_CODE::ERROR_CODE_NO_ERROR) {
m_equip.id = StringAsInt((*root)["data"]["equipid"].asString().c_str());
m_equip.isequiped = StringAsInt((*root)["data"]["status"].asString().c_str());
m_equip.type = (*root)["data"]["type"].asInt();
m_equip.model = (*root)["data"]["modelname"].asString();
m_equip.exp = (*root)["data"]["exp"].asInt();
m_equip.level = (*root)["data"]["level"].asInt();
g_pEquipManager->saveEquip(m_equip);
scheduleOnce(schedule_selector(Battle::pve_vector), 2.0f);
} else {
ALERT("小火鸡,不要作弊,小心被封号");
}
break;
}
default:
break;
}
}
示例5: getScale
void UtilManager::toast(string text, CAViewController* object) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, 180 * getScale(), 30 * getScale()));
back->setTag(TOAST_VIEW_TAG);
back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.5), 180 * getScale(), 30 * getScale()));
// title->setText(UTF8ToGBK::transferToGbk(text));
title->setText(text);
//title->setText("sssss");
// title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(15));
back->addSubview(title);
//CAApplication::getApplication()->getRootWindow()->getRootViewController()->getView()->addSubview(back);
back->runAction(CCFadeOut::create(1));
//CAApplication::getApplication()->getRootWindow()->addSubview(back);
object->getView()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例6: scheduleOnce
void OptionScene::goOut(Widget* layout, Widget* widget, Widget* newWidget)
{
layout->setEnabled(false);
newWidget->setEnabled(false);
auto buttonCenter = layout->convertToNodeSpace(widget->getWorldPosition());
auto layoutSize = layout->getContentSize();
auto buttonSize = widget->getContentSize();
layout->setAnchorPoint(Vec2(buttonCenter.x / layoutSize.width, buttonCenter.y / layoutSize.height));
layout->setPosition(buttonCenter);
auto moveAction = MoveTo::create(goIntoOutTime, buttonCenter);
layout->runAction(moveAction);
auto scaleAction = ScaleTo::create(goIntoOutTime, 1.0f);
layout->runAction(scaleAction);
auto fadeInAaction = FadeIn::create(goIntoOutTime);
widget->runAction(fadeInAaction);
int sacle;
if (buttonSize.width > buttonSize.height) {
sacle = this->getContentSize().height / buttonSize.height;
}
else {
sacle = this->getContentSize().width / buttonSize.width;
}
auto newScaleAction = ScaleTo::create(goIntoOutTime, 1 / sacle);
newWidget->runAction(newScaleAction);
newWidget->runAction(moveAction->clone());
auto fadeOutAaction = FadeOut::create(goIntoOutTime);
newWidget->runAction(fadeOutAaction);
scheduleOnce([this, newWidget, layout](float) {
this->removeChild(newWidget);
layout->setEnabled(true);
}, goIntoOutTime, "goOut");
}
示例7: setPosition
void ScoreText::initWithScore(int score, Point pos, Color3B col)
{
setPosition(pos);
Label* label = Label::createWithBMFont(MATH_FNT, "+" + nToString(score));//, NORMAL_TTF, 46.0f);
//label->setScale(1.1f);
label->setHorizontalAlignment(TextHAlignment::CENTER);
addChild(label);
label->setOpacity(0);
label->runAction(Sequence::create(
FadeIn::create(0.3f),
DelayTime::create(0.8f),
FadeOut::create(0.3f),
NULL));
/*
col.r *= 0.5;
col.g *= 0.5;
col.b *= 0.5;*/
label->setColor(Color3B::WHITE);
label->disableEffect();
label->runAction(TintTo::create(1.0f, col.r, col.g, col.b));
label->runAction(MoveBy::create(1.0f, Point(0, PY(0.05f))));
//label->enableGlow(Color4B(col));
//label->enableShadow();
scheduleOnce(schedule_selector(ScoreText::collect), 3.0f);
}
示例8: scheduleOnce
// on "init" you need to initialize your instance
bool Welcome::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
cocos2d::Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto label = LabelTTF::create("meijia", "Arial", 80);
// position the label on the center of the screen
label->setPosition(cocos2d::Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height/4*3));
// add the label as a child to this layer
//this->addChild(label, 1);
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("WelcomeBg.png");
// sprite->addChild(label, 1);
// position the sprite on the center of the screen
sprite->setPosition(cocos2d::Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(sprite, 0);
scheduleOnce(schedule_selector(Welcome::transToMeijia), 1.f);
return true;
}
示例9: unscheduleUpdate
void SGSHero::onDelay(SGMessage* message)
{
float time;
message->getFloat("time", &time);
unscheduleUpdate();
scheduleOnce(schedule_selector(SGSHero::startUpdate), time);
}
示例10: assert
bool ScatOrcScene::init()
{
assert(TRBaseScene::init());
_layer = Layer::create();
this->addChild(_layer);
auto sp2 = Sprite::create("images/white.png");
sp2->setScale(500);
_layer->addChild(sp2);
auto sp = Sprite::create("images/scatorc.png");
sp->setPosition(genPos({0.5,0.5}));
_layer->addChild(sp);
auto size = Director::getInstance()->getWinSize();
// sp->setScale(size.width/sp->getContentSize().width, size.height/sp->getContentSize().height);
sp->setOpacity(0);
sp->runAction(Sequence::create(FadeIn::create(0.1), DelayTime::create(0.1), FadeOut::create(0.1), nullptr));
scheduleOnce([this](float dt){
Director::getInstance()->replaceScene(WelcomeScene::create());
}, 0.4, "gamescene open");
return true;
}
示例11: createHero
//do initialization here
void LCBattleScene::initView()
{
backGround = Sprite::create("BackGround.png");
//backGround->setScale(3);
this->addChild(backGround);
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
backGround->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
lifeObj::setActiveRange(backGround->getContentSize());
lifeObj::setMap(backGround);
createHero();
addMonster(3);
hero->objList = monsterArr;
__NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(LCBattleScene::delteMonster), "delteMonster", NULL);
schedule(schedule_selector(LCBattleScene::followHero), 3.0f, -1, 1);
scheduleOnce(schedule_selector(LCBattleScene::test), 1);
scheduleUpdate();
// schedule(, 2, 2);
}
示例12: addChild
bool LoadingLayer::init()
{
if (!CCLayer::init())
return false;
//窗口大小
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
//当前层的位置
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCLayerColor* layercolor = CCLayerColor::create(ccc4(255,255,255,255),800,480) ;
addChild(layercolor) ;
//
// ui = TouchGroup::create();
//
// ui->addWidget(GUIReader::shareReader()->widgetFromJsonFile("UI/GameMainMenu_1/loadingLayer.ExportJson"));
// //ui->setVisible(false);
// addChild(ui, 2);
//hideDot();
num = 0;
CCSprite * logo = CCSprite::create("logo.png");
logo->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
this->addChild(logo,1000);
//schedule(schedule_selector(LoadingLayer::showDot),0.1);
logo->setScale(2.5);
scheduleOnce(schedule_selector(LoadingLayer::loading),0.1);
return true;
}
示例13: runAnimation
void LoadingLayer::onEnterTransitionDidFinish(){
// KKAds ads;
// ads.setAdsVisibility(false);
LayerColor::onEnterTransitionDidFinish();
runAnimation();
scheduleOnce(schedule_selector(LoadingLayer::updateToMainScene), 2.5f);
}
示例14: scheduleOnce
bool FieldScene::init()
{
if (!LayerColor::initWithColor(Color4B(255, 255, 255, 255)))
{
return false;
}
// 필드레이어
this->setFieldLayer( FieldLayer::create());
this->getFieldLayer()->setPosition(90, 10);
this->addChild(this->getFieldLayer(),1);
// 화면 틀 레이어
this->setFrameLayer(FrameLayer::create());
this->getFrameLayer()->setPosition(0, 0);
this->addChild(this->getFrameLayer(),2);
// 메뉴 레이어 띄우기
this->m_menuLayer = MenuLayer::create();
this->m_menuLayer->setPosition(0, 0);
this->addChild(m_menuLayer, 3);
// 테스트용 몬스터 등장용
scheduleOnce(schedule_selector(FieldScene::Battle), 3.0f);
return true;
}
示例15: switch
void GameWorld::OnCollision(b2Vec2 contact_normal)
{
// ignore collisions when the clown is in these states
switch(clown_->GetState())
{
case E_CLOWN_UP:
case E_CLOWN_ROCKET:
case E_CLOWN_BALLOON:
return;
}
// stop the clown's movement
clown_->GetBody()->SetLinearVelocity(b2Vec2_zero);
// update the clown's state
clown_->SetState(E_CLOWN_BOUNCE);
// save the normal at the point of contact
contact_normal_ = contact_normal;
// animate the platform
platform_->runAction(CCSequence::createWithTwoActions(CCAnimate::create(CCAnimationCache::sharedAnimationCache()->animationByName("platform_animation")), CCHide::create()));
// schedule the actual collision response after a short duration
scheduleOnce(schedule_selector(GameWorld::DoCollisionResponse), 0.15f);
has_game_begun_ = true;
SOUND_ENGINE->playEffect("platform.wav");
}