2023. 3. 14. 19:18ㆍcocos2dx
bool Layer_BG::init()
{
BGspr = nullptr;
//0000~0299.png
auto TCache = Director::getInstance();
for (int i = 0; i < BGLayerPicNums; i++)
{
TCache->getTextureCache()->addImageAsync(ccsf("BG/%d/%04d.png", layerNo, i), CC_CALLBACK_1(Layer_BG::loadingFinished, this));
}
BGspr = Sprite::create(ccsf("BG/%d/%04d.png", layerNo, picNo));
BGspr->setAnchorPoint(Vec2(0, 1));
//screen Size(768, 1280), pic size(1400, 860)
BGspr->setPosition(0, 1280);
BGspr->setTextureRect(Rect(0,0,768,860));
this->addChild(BGspr, 0);
scheduleUpdate();
return true;
}
void Layer_BG::loadingFinished(Texture2D* texture)
{
BGsprTextures[loadingNo++] = texture;
if (loadingNo == BGLayerPicNums) loadFinished = true;
}
로딩이 되고 있는 와중에도 다른 프로세스가 동작하게(근데 multi core는 아닌 듯)
로딩이 끝난 후에는 loadingFinished함수가 CALLBACK 처리된다
'cocos2dx' 카테고리의 다른 글
particle/using action function (0) | 2023.03.14 |
---|---|
clipping node (0) | 2023.03.14 |
save screenshot (0) | 2023.03.14 |
opencv -cocos2dx 연결 (0) | 2023.03.14 |
win build 테두리 없애기 (0) | 2023.03.14 |