本文整理汇总了C++中Director::runWithScene方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::runWithScene方法的具体用法?C++ Director::runWithScene怎么用?C++ Director::runWithScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::runWithScene方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
GLView* glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("My Game");
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
register_all_packages();
// create a scene. it's an autorelease object
Scene* scene = WelcomeScene::scene();
// run
director->runWithScene(scene);
SimpleAudioEngine::getInstance()->preloadBackgroundMusic("sounds/BgmCity.mp3");
SimpleAudioEngine::getInstance()->playBackgroundMusic("sounds/BgmCity.mp3",true);
return true;
}
示例2: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
EGLView* eglView = EGLView::getInstance();
director->setOpenGLView(eglView);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
Size screenSize = Director::getInstance()->getWinSize();
screenHeight = screenSize.height;
screenWidth = screenSize.width;
factorX = screenWidth / designWidth;
factorY = screenHeight / designHeight;
scaledWidth = screenWidth*factorX;
scaledHeight = screenHeight*factorY;
// create a scene. it's an autorelease object
Scene *scene = MainMenuLayer::scene();
// run
director->runWithScene(scene);
return true;
}
示例3: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
EGLView* glView = EGLView::getInstance();
director->setOpenGLView(glView);
Size size = director->getWinSize();
setDesignResolution();
// Set the design resolution
glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
// turn on display FPS
//director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
Scene *scene = MainTitleScene::create();
#else
Scene *scene = HelloWorld::scene();
#endif
// run
director->runWithScene(scene);
return true;
}
示例4: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
EGLView* eglView = EGLView::getInstance();
// チラツキ対策
// Director::getInstance()->setProjection(Director::Projection::_2D);
Director::getInstance()->setDepthTest(false);
Director::getInstance()->setOpenGLView(eglView);
// 800x480基準
eglView->setDesignResolutionSize(800.0 * 0.6,
480.0 * 0.6,
ResolutionPolicy::SHOW_ALL);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
// Scene *pScene = GameScene::scene();
auto *pScene = TitleSceneLoader::createScene();
// run
director->runWithScene(pScene);
return true;
}
示例5: changeScene
void SceneManager::changeScene( EnumSceneType enScenType, bool isTrans, float time )
{
Scene* pScene = getSceneByType(enScenType);
if(pScene == NULL)
{
return;
}
//TextureCache::sharedTextureCache()->removeUnusedTextures();
Director* pDirector = Director::getInstance();
Scene* curScene = pDirector->getRunningScene();
if(curScene == NULL)
{
pDirector->runWithScene(pScene);
}
else
{
if(isTrans)
{
pDirector->replaceScene(TransitionFade::create(time, pScene));
}
else
{
pDirector->replaceScene(pScene);
}
}
}
示例6: go
bool CGameSceneManager::go(SCENE_TYPE st)
{
Scene* scene = nullptr;
switch (st)
{
case ST_LOGIN:
{
CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
scene = pReader->createSceneWithNodeGraphFromFile("login_layer.ccbi");
delete pReader;
break;
}
case ST_LOBBY:
{
CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
scene = pReader->createSceneWithNodeGraphFromFile("lobby_layer.ccbi");
delete pReader;
break;
}
case ST_FORMATION:
{
scene = Scene::create();
scene->addChild(CFormationLayer::create());
break;
}
case ST_BATTLE_FIELD:
{
scene = Scene::create();
scene->addChild(CBattleFieldLayer::create()); // call init in create()
break;
}
case ST_SETTINGS:
break;
case ST_HOME:
{
CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
scene = pReader->createSceneWithNodeGraphFromFile("home_layer.ccbi");
delete pReader;
break;
}
default:
break;
}
if (scene)
{
Director* pDirector = Director::getInstance();
if (pDirector->getRunningScene())
{
TransitionFade* trans = TransitionFade::create(.2f, scene, Color3B(255, 255, 255));
pDirector->replaceScene(trans);
}
else
{
pDirector->runWithScene(scene);
}
}
return true;
}
示例7: Init
bool FrameManager::Init()
{
RegisterAllFrame();
mCurScene = Scene::create();
Director* director = Director::getInstance();
director->runWithScene(mCurScene);
return true;
}
示例8: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* pDirector = Director::sharedDirector();
EGLView* pEGLView = EGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution
pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
Size frameSize = pEGLView->getFrameSize();
vector<string> searchPath;
// In this demo, we select resource according to the frame's height.
// If the resource size is different from design resolution size, you need to set contentScaleFactor.
// We use the ratio of resource's height to the height of design resolution,
// this can make sure that the resource's height could fit for the height of design resolution.
// if the frame's height is larger than the height of medium resource size, select large resource.
if (frameSize.height > mediumResource.size.height)
{
searchPath.push_back(largeResource.directory);
pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small resource size, select medium resource.
else if (frameSize.height > smallResource.size.height)
{
searchPath.push_back(mediumResource.directory);
pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium resource size, select small resource.
else
{
searchPath.push_back(smallResource.directory);
pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
}
// set searching path
FileUtils::sharedFileUtils()->setSearchPaths(searchPath);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
示例9: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
Size screenSize = EGLView::sharedOpenGLView()->getFrameSize();
//Size designSize = CCSizeMake(1600, 900);
Size designSize = CCSizeMake(12*101, 12*81);
std::vector<std::string> searchPaths;
if (screenSize.height > 320)
{
searchPaths.push_back("hd");
searchPaths.push_back("sd");
Size resourceSize = CCSizeMake(12*101, 12*81);
//pDirector->setContentScaleFactor(960.0f/designSize.height);
///pDirector->setContentScaleFactor(1.0f);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}
else
{
searchPaths.push_back("sd");
pDirector->setContentScaleFactor(640.0f/designSize.height);
}
FileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
EGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
// turn on display FPS
//pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
//Scene *pScene = GameplayScene::scene();
Scene *scene;
if (_levelToLaunch == nullptr)
{
scene = MainMenuLayer::scene();
}
else
{
auto ms = Bomber::Frontend::MenuSelections::getInstance();
ms->setLevelFilename(_levelToLaunch);
ms->setLevelName("test");
scene = GameplayScene::scene();
}
// run
pDirector->runWithScene(scene);
return true;
}
示例10: go
void SceneManager::go(Layer* layer)
{
Director *director = Director::getInstance();
Scene *newScene = SceneManager::wrap(layer);
if ( director->getRunningScene() )
{
s_nSceneIdx++;
s_nSceneIdx = s_nSceneIdx % MAX_LAYER;
Director::getInstance()->replaceScene(createTransition(s_nSceneIdx, TRANSITION_DURATION, newScene));
}
else
{
director->runWithScene(newScene);
}
}
示例11: go
void SceneManager::go(Scene* scene)
{
Layer* layer = (Layer*)scene;
Director *director = Director::getInstance();
Scene *newScene = SceneManager::wrap(layer);
if ( director->getRunningScene() )
{
director->replaceScene(newScene);
}
else
{
director->runWithScene(newScene);
}
}
示例12: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director & GLView
Director *director = Director::getInstance();
director->setProjection(Director::Projection::_2D);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
// Scene *scene = CCColorMatrixFunctionalTestScene::scene();
Scene *scene = MainMenuScene::scene();
// run
director->runWithScene(scene);
return true;
}
示例13: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* pDirector = Director::sharedDirector();
EGLView* pEGLView = EGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
示例14: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
EGLView* eglView = EGLView::getInstance();
director->setOpenGLView(eglView);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *scene = MainScene::getMainScene();
// run
director->runWithScene(scene);
return true;
}
示例15: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director *director = Director::getInstance();
director->setOpenGLView(EGLView::getInstance());
Size screenSize = EGLView::getInstance()->getFrameSize();
Size designSize = Size(480, 320);
std::vector<std::string> searchPaths;
if (screenSize.height > 320)
{
searchPaths.push_back("hd");
searchPaths.push_back("sd");
director->setContentScaleFactor(640.0f/designSize.height);
}
else
{
searchPaths.push_back("sd");
director->setContentScaleFactor(320.0f/designSize.height);
}
FileUtils::getInstance()->setSearchPaths(searchPaths);
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *scene = HelloWorld::scene();
// run
director->runWithScene(scene);
return true;
}