-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneTitle.cpp
79 lines (69 loc) · 2.16 KB
/
SceneTitle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "Graphics/Graphics.h"
#include "SceneTitle.h"
#include "SceneGame.h"
#include "SceneManager.h"
#include "SceneLoading.h"
#include "Input/Input.h"
#include "Audio/Audio.h"
// 初期化
void SceneTitle::Initialize()
{
// スプライト初期化
sprite = new Sprite("Data/Sprite/Title.png");
//sprite = new Sprite("Data/Sprite/トガ.jpg");
// タイトルBGM
TitleBGM = Audio::Instance().LoadAudioSource("Data/Audio/Title.wav");
}
// 終了化
void SceneTitle::Finalize()
{
// スプライト終了化
if (sprite != nullptr)
{
delete sprite;
sprite = nullptr;
}
}
//更新処理
void SceneTitle::Update(float elapsedTime)
{
// タイトルBGM
TitleBGM->Play(true);
GamePad& gamePad = Input::Instance().GetGamePad();
// なにかボタンを押したらローディングシーンを挟んでゲームシーンを切り替え
const GamePadButton anyButton =
GamePad::BTN_A
| GamePad::BTN_B
| GamePad::BTN_X
| GamePad::BTN_Y;
if (gamePad.GetButtonDown() & anyButton)
{
SceneManager::Instance().ChangeScene(new SceneLoading(new SceneGame));
}
}
// 描画処理
void SceneTitle::Render()
{
Graphics& graphics = Graphics::Instance();
ID3D11DeviceContext* dc = graphics.GetDeviceContext();
ID3D11RenderTargetView* rtv = graphics.GetRenderTargetView();
ID3D11DepthStencilView* dsv = graphics.GetDepthStencilView();
// 画面クリア&レンダーターゲット設定
FLOAT color[] = { 0.0f,0.0f,0.5f,1.0f }; // RGBA(0.0~1.0)
dc->ClearRenderTargetView(rtv, color);
dc->ClearDepthStencilView(dsv, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
dc->OMSetRenderTargets(1, &rtv, dsv);
// 2Dスプライト描画
{
float screenWidth = static_cast<float>(graphics.GetScreenWidth());
float screenHeight = static_cast<float>(graphics.GetScreenHeight());
float textureWidth = static_cast<float>(sprite->GetTextureWidth());
float textureHeight = static_cast<float>(sprite->GetTextureHeight());
// タイトルスプライト描画
sprite->Render(dc,
0, 0, screenWidth, screenHeight,
0, 0, textureWidth, textureHeight,
0,
1, 1, 1, 1);
}
}