図0101a
図0101b
サンプルではおおむねファイルはこのような構造になっています。
#pragma once
#include "stdafx.h"
namespace basecross {
//--------------------------------------------------------------------------------------
// ゲームステージクラス
//--------------------------------------------------------------------------------------
class GameStage : public Stage {
//ビューとライトの作成
void CreateViewLight();
public:
//構築と破棄
GameStage() :Stage() {}
virtual ~GameStage() {}
//初期化
virtual void OnCreate()override;
};
}
//end basecross
//初期化
virtual void OnCreate()override;
#include "stdafx.h"
#include "Project.h"
namespace basecross {
//--------------------------------------------------------------------------------------
// ゲームステージクラス実体
//--------------------------------------------------------------------------------------
//ビューとライトの作成
void GameStage::CreateViewLight() {
auto PtrView = CreateView<SingleView>();
//ビューのカメラの設定
auto PtrCamera = PtrView->GetCamera();
PtrCamera->SetEye(Vec3(0.0f, 5.0f, -5.0f));
PtrCamera->SetAt(Vec3(0.0f, 0.0f, 0.0f));
//シングルライトの作成
auto PtrSingleLight = CreateLight<SingleLight>();
//ライトの設定
PtrSingleLight->GetLight().SetPositionToDirectional(-0.25f, 1.0f, -0.25f);
}
void GameStage::OnCreate() {
try {
//ビューとライトの作成
CreateViewLight();
}
catch (...) {
throw;
}
}
}
//end basecross
#pragma once
#include "stdafx.h"
namespace basecross{
//--------------------------------------------------------------------------------------
/// ゲームシーン
//--------------------------------------------------------------------------------------
class Scene : public SceneBase{
public:
//--------------------------------------------------------------------------------------
/*!
@brief コンストラクタ
*/
//--------------------------------------------------------------------------------------
Scene() :SceneBase(){}
//--------------------------------------------------------------------------------------
/*!
@brief デストラクタ
*/
//--------------------------------------------------------------------------------------
virtual ~Scene(){}
//--------------------------------------------------------------------------------------
/*!
@brief 初期化
@return なし
*/
//--------------------------------------------------------------------------------------
virtual void OnCreate() override;
//--------------------------------------------------------------------------------------
/*!
@brief イベント取得
@return なし
*/
//--------------------------------------------------------------------------------------
virtual void OnEvent(const shared_ptr<Event>& event) override;
};
}
//end basecross
#include "stdafx.h"
#include "Project.h"
namespace basecross{
//--------------------------------------------------------------------------------------
/// ゲームシーン
//--------------------------------------------------------------------------------------
void Scene::OnCreate() {
try {
//クリアする色を設定
Col4 Col;
Col.set(31.0f / 255.0f,30.0f / 255.0f,71.0f / 255.0f,255.0f / 255.0f);
SetClearColor(Col);
//自分自身にイベントを送る
//これにより各ステージやオブジェクトがCreate時にシーンにアクセスできる
PostEvent(0.0f, GetThis<ObjectInterface>(), GetThis<Scene>(), L"ToGameStage");
}
catch (...) {
throw;
}
}
void Scene::OnEvent(const shared_ptr<Event>& event) {
if (event->m_MsgStr == L"ToGameStage") {
//最初のアクティブステージの設定
ResetActiveStage<GameStage>();
}
}
}
//end basecross
//自分自身にイベントを送る
//これにより各ステージやオブジェクトがCreate時にシーンにアクセスできる
PostEvent(0.0f, GetThis<ObjectInterface>(), GetThis<Scene>(), L"ToGameStage");
#pragma once
#include "stdafx.h"
namespace basecross{
//--------------------------------------------------------------------------------------
/// ゲームシーン
//--------------------------------------------------------------------------------------
class Scene : public SceneBase{
public:
//--------------------------------------------------------------------------------------
/*!
@brief コンストラクタ
*/
//--------------------------------------------------------------------------------------
Scene() :SceneBase(){}
//--------------------------------------------------------------------------------------
/*!
@brief デストラクタ
*/
//--------------------------------------------------------------------------------------
virtual ~Scene(){}
//--------------------------------------------------------------------------------------
/*!
@brief 初期化
@return なし
*/
//--------------------------------------------------------------------------------------
virtual void OnCreate() override;
};
}
//end basecross
#include "stdafx.h"
#include "Project.h"
namespace basecross{
//--------------------------------------------------------------------------------------
/// ゲームシーン
//--------------------------------------------------------------------------------------
void Scene::OnCreate(){
try {
//クリアする色を設定
Col4 Col;
Col.set(31.0f / 255.0f,30.0f / 255.0f,71.0f / 255.0f,255.0f / 255.0f);
SetClearColor(Col);
//最初のアクティブステージの設定
ResetActiveStage<GameStage>();
}
catch (...) {
throw;
}
}
}
//end basecross