本文整理汇总了C++中TextureLoader::loadAsync方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureLoader::loadAsync方法的具体用法?C++ TextureLoader::loadAsync怎么用?C++ TextureLoader::loadAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureLoader
的用法示例。
在下文中一共展示了TextureLoader::loadAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preload
void MainMenuController::preload() {
// Tutorial button
GameController* gc = GameController::create(TUTORIAL_KEY, TUTORIAL_FILE);
gc->preload();
_tutButt = MainMenuButton::create(gc);
_tutButt->index = -1;
_tutButt->loadTextures("textures/Tutorial/tutorial.png", "textures/Tutorial/tutorial.png");
_tutButt->setTouchEnabled(true);
//Add event listener
_tutButt->addTouchEventListener([&](Ref* sender, ui::Widget::TouchEventType type) {
switch (type) {
case ui::Widget::TouchEventType::ENDED:
_tutButt = ((MainMenuButton*)sender);
_currController = _tutButt->index;
_activeController = _tutButt->getController();
_rootnode->removeAllChildren();
_activeController->initialize(_rootnode);
}
});
_tutButt->retain();
loadGameController(LEVEL_ONE_KEY, LEVEL_ONE_FILE);
loadGameController(LEVEL_TWO_KEY, LEVEL_TWO_FILE);
loadGameController(LEVEL_THREE_KEY, LEVEL_THREE_FILE);
loadGameController(LEVEL_FOUR_KEY, LEVEL_FOUR_FILE);
loadGameController(LEVEL_FIVE_KEY, LEVEL_FIVE_FILE);
loadGameController(LEVEL_SIX_KEY, LEVEL_SIX_FILE);
loadGameController(LEVEL_SEVEN_KEY, LEVEL_SEVEN_FILE);
loadGameController(LEVEL_EIGHT_KEY, LEVEL_EIGHT_FILE);
loadGameController(LEVEL_NINE_KEY, LEVEL_NINE_FILE);
// Load the textures (Autorelease objects)
_assets = AssetManager::getInstance()->getCurrent();
TextureLoader* tloader = (TextureLoader*)_assets->access<Texture2D>();
tloader->loadAsync(EXPOSURE_BAR, "textures/exposure_bar.png");
tloader->loadAsync(EXPOSURE_FRAME, "textures/exposure_bar_frame.png");
tloader->loadAsync(DUDE_TEXTURE, "textures/player_animation.png");
tloader->loadAsync("dudepool", "textures/Level Pool/Shade_Swim_Animation.png");
tloader->loadAsync(PEDESTRIAN_TEXTURE, "textures/Pedestrian.png");
tloader->loadAsync(PEDESTRIAN_SHADOW_TEXTURE, "textures/Pedestrian_S.png");
tloader->loadAsync(PEDESTRIAN_POOL_TEXTURE, "textures/Level Pool/Level2_RotationP_Animation_New.png");
tloader->loadAsync(PEDESTRIAN_POOL_SHADOW_TEXTURE, "textures/Level2_RotationP_Animation_S.png");
tloader->loadAsync(INDICATOR, "textures/indicator.png");
tloader->loadAsync(CAR_TEXTURE, "textures/car_animation.png");
tloader->loadAsync(CAR_SHADOW_TEXTURE, "textures/Car1_S.png");
tloader->loadAsync(GOAL_TEXTURE, "textures/caster_animation.png");
//tloader->loadAsync("goalpool", "textures/caster_animation.png");
tloader->loadAsync(WIN_IMAGE, "textures/menu/Win Icon.png");
tloader->loadAsync(LOSE_IMAGE, "textures/menu/lose_icon.png");
tloader->loadAsync(WIN_TEXTURE, "textures/Shade_Win.png");
tloader->loadAsync(LOSE_TEXTURE, "textures/Shade_Sun.png");
_assets->loadAsync<Sound>(GAME_MUSIC, "sounds/DD_Main.mp3");
_assets->loadAsync<Sound>(WIN_MUSIC, "sounds/win.mp3");
_assets->loadAsync<Sound>(LOSE_MUSIC, "sounds/lose.mp3");
_assets->loadAsync<Sound>(LATCH_SOUND, "sounds/latch.mp3");
_assets->loadAsync<Sound>(SIGHTED_SOUND, "sounds/sighted.mp3");
_assets->loadAsync<Sound>(RUN_SOUND, "sounds/run.mp3");
JSONReader reader;
reader.initWithFile(STATIC_OBJECTS);
if (!reader.startJSON()) {
CCASSERT(false, "Failed to load static objects");
return;
}
int count = reader.startArray("types");
for (int index = 0; index < count; index++) {
reader.startObject();
string name = reader.getString("name");
string imageFormat = reader.getString("imageFormat");
string shadowImageFormat = reader.getString("shadowImageFormat");
if (shadowImageFormat == "") {
shadowImageFormat = imageFormat;
}
tloader->loadAsync(name + OBJECT_TAG, "textures/static_objects/" + name + "." + imageFormat);
tloader->loadAsync(name + SHADOW_TAG, "textures/static_objects/" + name + "_S." + shadowImageFormat);
reader.endObject();
reader.advance();
}
reader.endArray();
reader.endJSON();
// Background
tloader->loadAsync(MENU_BACKGROUND_KEY, "textures/menu/Level Background-01.png");
}