本文整理汇总了C++中Director::getRunningScene方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::getRunningScene方法的具体用法?C++ Director::getRunningScene怎么用?C++ Director::getRunningScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::getRunningScene方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: handle_signal
void handle_signal(int signal) {
static int internal_state = 0;
ScriptingCore* sc = ScriptingCore::getInstance();
// should start everything back
Director* director = Director::getInstance();
if (director->getRunningScene()) {
director->popToRootScene();
} else {
PoolManager::sharedPoolManager()->finalize();
if (internal_state == 0) {
//sc->dumpRoot(NULL, 0, NULL);
sc->start();
internal_state = 1;
} else {
sc->runScript("hello.js");
internal_state = 0;
}
}
}
示例6: go
bool CGameSceneManager::go(SCENE_TYPE st)
{
Scene* scene = nullptr;
switch (st)
{
case ST_LOGIN:
{
scene = CCBReadHelper::readScene("login_layer.ccbi");
break;
}
case ST_LOBBY:
{
scene = CCBReadHelper::readScene("lobby_layer.ccbi");
break;
}
case ST_MATCH:
{
scene = CCBReadHelper::readScene("pitch_layer.ccbi");
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: setLightUniforms
void MeshCommand::setLightUniforms()
{
Director *director = Director::getInstance();
auto scene = director->getRunningScene();
const auto& conf = Configuration::getInstance();
int maxDirLight = conf->getMaxSupportDirLightInShader();
int maxPointLight = conf->getMaxSupportPointLightInShader();
int maxSpotLight = conf->getMaxSupportSpotLightInShader();
auto &lights = scene->getLights();
auto glProgram = _glProgramState->getGLProgram();
if (_glProgramState->getVertexAttribsFlags() & (1 << GLProgram::VERTEX_ATTRIB_NORMAL))
{
resetLightUniformValues();
GLint enabledDirLightNum = 0;
GLint enabledPointLightNum = 0;
GLint enabledSpotLightNum = 0;
Vec3 ambientColor;
for (const auto& light : lights)
{
bool useLight = light->isEnabled() && ((unsigned int)light->getLightFlag() & _lightMask);
if (useLight)
{
float intensity = light->getIntensity();
switch (light->getLightType())
{
case LightType::DIRECTIONAL:
{
if(enabledDirLightNum < maxDirLight)
{
auto dirLight = static_cast<DirectionLight *>(light);
Vec3 dir = dirLight->getDirectionInWorld();
dir.normalize();
const Color3B &col = dirLight->getDisplayedColor();
s_dirLightUniformColorValues[enabledDirLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity);
s_dirLightUniformDirValues[enabledDirLightNum] = dir;
++enabledDirLightNum;
}
}
break;
case LightType::POINT:
{
if(enabledPointLightNum < maxPointLight)
{
auto pointLight = static_cast<PointLight *>(light);
Mat4 mat= pointLight->getNodeToWorldTransform();
const Color3B &col = pointLight->getDisplayedColor();
s_pointLightUniformColorValues[enabledPointLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity);
s_pointLightUniformPositionValues[enabledPointLightNum] = Vec3(mat.m[12], mat.m[13], mat.m[14]);
s_pointLightUniformRangeInverseValues[enabledPointLightNum] = 1.0f / pointLight->getRange();
++enabledPointLightNum;
}
}
break;
case LightType::SPOT:
{
if(enabledSpotLightNum < maxSpotLight)
{
auto spotLight = static_cast<SpotLight *>(light);
Vec3 dir = spotLight->getDirectionInWorld();
dir.normalize();
Mat4 mat= light->getNodeToWorldTransform();
const Color3B &col = spotLight->getDisplayedColor();
s_spotLightUniformColorValues[enabledSpotLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity);
s_spotLightUniformPositionValues[enabledSpotLightNum] = Vec3(mat.m[12], mat.m[13], mat.m[14]);
s_spotLightUniformDirValues[enabledSpotLightNum] = dir;
s_spotLightUniformInnerAngleCosValues[enabledSpotLightNum] = spotLight->getCosInnerAngle();
s_spotLightUniformOuterAngleCosValues[enabledSpotLightNum] = spotLight->getCosOuterAngle();
s_spotLightUniformRangeInverseValues[enabledSpotLightNum] = 1.0f / spotLight->getRange();
++enabledSpotLightNum;
}
}
break;
case LightType::AMBIENT:
{
auto ambLight = static_cast<AmbientLight *>(light);
const Color3B &col = ambLight->getDisplayedColor();
ambientColor += Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity);
}
break;
default:
break;
}
}
}
if (0 < maxDirLight)
{
glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_dirLightUniformColorName), (GLfloat*)(&s_dirLightUniformColorValues[0]), (unsigned int)s_dirLightUniformColorValues.size());
glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_dirLightUniformDirName), (GLfloat*)(&s_dirLightUniformDirValues[0]), (unsigned int)s_dirLightUniformDirValues.size());
}
if (0 < maxPointLight)
{
glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformColorName), (GLfloat*)(&s_pointLightUniformColorValues[0]), (unsigned int)s_pointLightUniformColorValues.size());
glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformPositionName), (GLfloat*)(&s_pointLightUniformPositionValues[0]), (unsigned int)s_pointLightUniformPositionValues.size());
glProgram->setUniformLocationWith1fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformRangeInverseName), (GLfloat*)(&s_pointLightUniformRangeInverseValues[0]), (unsigned int)s_pointLightUniformRangeInverseValues.size());
}
//.........这里部分代码省略.........
示例8: createScene
Scene* BattleArena::createScene()
{
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// some upfront items that we need
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Director* dirs = Director::getInstance();
Size visibleSize = dirs->getVisibleSize();
Vec2 origin = dirs->getVisibleOrigin();
Size playingSize = Size(visibleSize.width, visibleSize.height - (visibleSize.height/8)); // actual playing size to work with
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// create a scene
// 'scene' is an autorelease object
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scene* scene = Scene::create();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// create a node to hold non-sprites.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Node* nodeItems = Node::create();
nodeItems->setName("nodeItems");
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// create a node to hold menu
// create a menu
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Node* menuNode = Node::create();
menuNode->setName("menuNode");
int index = 2;
MenuItemFont* menuItem3 = MenuItemFont::create("Summon Pikachu");
menuItem3->setFontNameObj("fonts/Marker Felt.ttf");
menuItem3->setFontSizeObj(32);
menuItem3->setName("summon_pikachu");
menuItem3->setVisible(true);
menuItem3->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2).x,
(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height).y - (index) * 40));
menuItem3->setCallback([&](cocos2d::Ref *sender) {
Director* dirs = Director::getInstance();
Scene* runningScene = dirs->getRunningScene();
SpriteFrameCache* spritecache = SpriteFrameCache::getInstance();
spritecache->addSpriteFramesWithFile("learning/PIKACHU.plist");
Sprite* newSprite = Sprite::createWithSpriteFrameName("0.gif");
int xRandom = random(0, int(dirs->getVisibleSize().width));
int yRandom = random(246, 266);
newSprite->setPosition(xRandom, yRandom);
newSprite->setName("sprite3");
newSprite->setAnchorPoint(Vec2(0.5,0.5));
runningScene->addChild(newSprite,1);
Vector<SpriteFrame*> animFrames;
int frames = 112;
animFrames.reserve(frames);
char gif[8] = {0};
for(int index_frames = 0 ; index_frames < frames ; index_frames++){
sprintf(gif, "%d.gif", index_frames);
animFrames.pushBack(spritecache->getSpriteFrameByName(gif));
}
// create the animation out of the frames
Animation* animation = Animation::createWithSpriteFrames(animFrames, 0.05f);
Animate* animate = Animate::create(animation);
// run it and repeat it forever
newSprite->runAction(RepeatForever::create(animate));
});
Menu* menu = Menu::create(menuItem3, NULL);
menu->setName("menu");
menuNode->addChild(menu, 1);
menu->setPosition(Vec2::ZERO);
scene->addChild(menuNode, 2);
// return the scene
return scene;
}