当前位置: 首页>>代码示例>>C++>>正文


C++ Bundle::loadScene方法代码示例

本文整理汇总了C++中Bundle::loadScene方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::loadScene方法的具体用法?C++ Bundle::loadScene怎么用?C++ Bundle::loadScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bundle的用法示例。


在下文中一共展示了Bundle::loadScene方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

Scene* Scene::load(const char* filePath)
{
    if (endsWith(filePath, ".gpb", true))
    {
        Scene* scene = NULL;
        Bundle* bundle = Bundle::create(filePath);
        if (bundle)
        {
            scene = bundle->loadScene();
            SAFE_RELEASE(bundle);
        }
        return scene;
    }
    return SceneLoader::load(filePath);
}
开发者ID:1timmy,项目名称:GamePlay,代码行数:15,代码来源:Scene.cpp

示例2: cameraPosition

void Audio3DTest::initialize()
{
    setMultiTouch(true);
    _font = Font::create("res/common/arial18.gpb");
    // Load game scene from file
    Bundle* bundle = Bundle::create("res/common/box.gpb");
    _scene = bundle->loadScene();
    SAFE_RELEASE(bundle);

    // Get light node
    Node* lightNode = _scene->findNode("directionalLight1");
    Light* light = lightNode->getLight();

    // Initialize box model
    Node* boxNode = _scene->findNode("box");
    Model* boxModel = boxNode->getModel();
    Material* boxMaterial = boxModel->setMaterial("res/common/box.material");
    boxMaterial->getParameter("u_lightColor")->setValue(light->getColor());
    boxMaterial->getParameter("u_lightDirection")->setValue(lightNode->getForwardVectorView());

    // Remove the cube from the scene but keep a reference to it.
    _cubeNode = boxNode;
    _cubeNode->addRef();
    _scene->removeNode(_cubeNode);

    loadGrid(_scene);

    // Initialize cameraa
    Vector3 cameraPosition(5, 5, 1);
    if (Camera* camera = _scene->getActiveCamera())
    {
        camera->getNode()->getTranslation(&cameraPosition);
    }

    _fpCamera.initialize();
    _fpCamera.setPosition(cameraPosition);
    _scene->addNode(_fpCamera.getRootNode());
    _scene->setActiveCamera(_fpCamera.getCamera());

    _gamepad = getGamepad(0);
    GP_ASSERT(_gamepad);
    _gamepad->getForm()->setConsumeInputEvents(false);
}
开发者ID:ArtProgrammer,项目名称:game-play,代码行数:43,代码来源:Audio3DTest.cpp

示例3: initialize

void SpaceshipGame::initialize()
{
    // TODO: Not working on iOS
    // Display the gameplay splash screen for at least 1 second.
    displayScreen(this, &SpaceshipGame::drawSplash, NULL, 1000L);

    // Create our render state block that will be reused across all materials
    _stateBlock = RenderState::StateBlock::create();
    _stateBlock->setDepthTest(true);
    _stateBlock->setCullFace(true);
    _stateBlock->setBlend(true);
    _stateBlock->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
    _stateBlock->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);

    // Load our scene from file
    Bundle* bundle = Bundle::create("res/spaceship.gpb");
    _scene = bundle->loadScene();
    SAFE_RELEASE(bundle);

    // Update the aspect ratio for our scene's camera to match the current device resolution
    _scene->getActiveCamera()->setAspectRatio((float)getWidth() / (float)getHeight());

    // Initialize scene data
    initializeSpaceship();
    initializeEnvironment();

    // Create a background audio track
    _backgroundSound = AudioSource::create("res/background.ogg");
    if (_backgroundSound)
        _backgroundSound->setLooped(true);
    
    // Create font
    _font = Font::create("res/airstrip28.gpb");

    // Store camera node
    _cameraNode = _scene->findNode("camera1");

    // Store initial ship and camera positions
    _initialShipPos = _shipGroupNode->getTranslation();
    _initialShipRot = _shipGroupNode->getRotation();
    _initialCameraPos = _cameraNode->getTranslation();
}
开发者ID:Jaegermeiste,项目名称:GamePlay,代码行数:42,代码来源:SpaceshipGame.cpp

示例4: initialize

void TemplateGame::initialize()
{
    // Load game scene from file
    Bundle* bundle = Bundle::create("res/box.gpb");
    _scene = bundle->loadScene();
    SAFE_RELEASE(bundle);

    // Set the aspect ratio for the scene's camera to match the current resolution
    _scene->getActiveCamera()->setAspectRatio((float)getWidth() / (float)getHeight());
    
    // Get light node
    Node* lightNode = _scene->findNode("directionalLight");
    Light* light = lightNode->getLight();

    // Initialize box model
    Node* boxNode = _scene->findNode("box");
    Model* boxModel = boxNode->getModel();
    Material* boxMaterial = boxModel->setMaterial("res/box.material");
	boxMaterial->getParameter("u_ambientColor")->setValue(_scene->getAmbientColor());
	boxMaterial->getParameter("u_ambientColor")->setValue(_scene->getAmbientColor());
    boxMaterial->getParameter("u_lightColor")->setValue(light->getColor());
    boxMaterial->getParameter("u_lightDirection")->setValue(lightNode->getForwardVectorView());
}
开发者ID:kcunney,项目名称:GamePlay,代码行数:23,代码来源:TemplateGame.cpp

示例5: lua_Bundle_loadScene

static int lua_Bundle_loadScene(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 1:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA))
            {
                Bundle* instance = getInstance(state);
                void* returnPtr = ((void*)instance->loadScene());
                if (returnPtr)
                {
                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
                    object->instance = returnPtr;
                    object->owns = true;
                    luaL_getmetatable(state, "Scene");
                    lua_setmetatable(state, -2);
                }
                else
                {
                    lua_pushnil(state);
                }

                return 1;
            }

            lua_pushstring(state, "lua_Bundle_loadScene - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        case 2:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
            {
                // Get parameter 1 off the stack.
                const char* param1 = gameplay::ScriptUtil::getString(2, false);

                Bundle* instance = getInstance(state);
                void* returnPtr = ((void*)instance->loadScene(param1));
                if (returnPtr)
                {
                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
                    object->instance = returnPtr;
                    object->owns = true;
                    luaL_getmetatable(state, "Scene");
                    lua_setmetatable(state, -2);
                }
                else
                {
                    lua_pushnil(state);
                }

                return 1;
            }

            lua_pushstring(state, "lua_Bundle_loadScene - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:73,代码来源:lua_Bundle.cpp


注:本文中的Bundle::loadScene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。