异步加载图片loading


void onEnter() override;

void loadingCallBack(Texture2D *texture);


void LoadingScene::onEnter(){

// add background to current scene

Sprite *background = Sprite::create("splash.png");

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

    Point origin = Director::getInstance()->getVisibleOrigin();

background->setPosition(origin.x + visibleSize.width/2, origin.y + visibleSize.height/2);

this->addChild(background);


// start ansyc method load the atlas.png

Director::getInstance()->getTextureCache()->addImageAsync("atlas.png", CC_CALLBACK_1(LoadingScene::loadingCallBack, this));

}


void LoadingScene::loadingCallBack(Texture2D *texture){

AtlasLoader::getInstance()->loadAtlas("atlas.txt", texture);


// After loading the texture , preload all the sound

SimpleAudioEngine::getInstance()->preloadEffect("sfx_die.ogg");

SimpleAudioEngine::getInstance()->preloadEffect("sfx_hit.ogg");

SimpleAudioEngine::getInstance()->preloadEffect("sfx_point.ogg");

SimpleAudioEngine::getInstance()->preloadEffect("sfx_swooshing.ogg");

SimpleAudioEngine::getInstance()->preloadEffect("sfx_wing.ogg");


// After load all the things, change the scene to new one

//auto scene = HelloWorld::createScene();

auto scene = WelcomeScene::create();

TransitionScene *transition = TransitionFade::create(1, scene);

Director::getInstance()->replaceScene(transition);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值