응애맘마조
장면전환 본문
씬이 바뀌면서 효과를 주는 것이 과제였습니다.
//stage01.h
#pragma once
class Stage01 : public Scene
{
public:
ObTileMap* map;
ObImage* coin;
bool fadeOut;
float fadeIn;
public:
virtual void Init() override;
virtual void Release() override;
virtual void Update() override;
virtual void LateUpdate() override;
virtual void Render() override;
virtual void ResizeScreen() override;
};
//stage01.cpp
#include "stdafx.h"
void Stage01::Init()
{
map = new ObTileMap();
map->file = "map2.txt";
map->Load();
coin->scale = Vector2(500.0f, 500.0f);
coin->maxFrame.x = 4;
LIGHT->light.inColor = Color(0.5f, 0.5f, 0.5f, 0.5f);
LIGHT->light.lights[0].radius = 0.0f;
fadeOut = false;
fadeIn = 1.0f;
}
void Stage01::Release()
{
SafeDelete(map);
}
void Stage01::Update()
{
ImGui::Text("FPS : %d", TIMER->GetFramePerSecond());
if (ImGui::Button("Stage02"))
{
fadeOut = true;
SCENE->ChangeScene("Stage02", 1.0f);
}
if (fadeOut)
{
LIGHT->light.lights[0].radius -= 1000.0f * DELTA;
}
if (fadeIn > 0.0f)
{
LIGHT->light.lights[0].radius += 1000.0f * DELTA;
fadeIn -= DELTA;
}
if (INPUT->KeyPress('D'))
{
coin->MoveWorldPos(RIGHT * 200.0f * DELTA);
}
if (INPUT->KeyPress(VK_UP))
{
CAM->position += UP * 300.0f * DELTA;
}
else if (INPUT->KeyPress(VK_DOWN))
{
CAM->position += DOWN * 300.0f * DELTA;
}
if (INPUT->KeyPress(VK_RIGHT))
{
CAM->position += RIGHT * 300.0f * DELTA;
}
else if (INPUT->KeyPress(VK_LEFT))
{
CAM->position += LEFT * 300.0f * DELTA;
}
map->Update();
coin->Update();
}
void Stage01::LateUpdate()
{
}
void Stage01::Render()
{
map->Render();
coin->Render();
}
void Stage01::ResizeScreen()
{
}
//stage02.h
#pragma once
class Stage02 : public Scene
{
public:
ObTileMap* map;
ObImage* coin;
bool whiteOut;
float whiteIn;
public:
virtual void Init() override;
virtual void Release() override; //해제
virtual void Update() override;
virtual void LateUpdate() override;//갱신
virtual void Render() override;
virtual void ResizeScreen() override;
};
//stage02.cpp
#include "stdafx.h"
void Stage02::Init()
{
map = new ObTileMap();
map->file = "map1.txt";
map->Load();
coin->scale = Vector2(500.0f, 500.0f);
coin->maxFrame.x = 4;
LIGHT->light.lights[0].radius = 1000.0f;
LIGHT->light.inColor = Color(1.0f, 1.0f, 1.0f, 0.5f);
whiteOut = false;
whiteIn = 1.0f;
}
void Stage02::Release()
{
SafeDelete(map);
}
void Stage02::Update()
{
ImGui::Text("FPS : %d", TIMER->GetFramePerSecond());
if (ImGui::Button("Stage01"))
{
SCENE->ChangeScene("Stage01", 1.0f);
whiteOut = true;
//return;
}
if (whiteOut)
{
LIGHT->light.inColor.x += 0.5f * DELTA;
LIGHT->light.inColor.y += 0.5f * DELTA;
LIGHT->light.inColor.z += 0.5f * DELTA;
}
if (whiteIn > 0.0f)
{
whiteIn -= DELTA;
LIGHT->light.inColor.x -= 0.5f * DELTA;
LIGHT->light.inColor.y -= 0.5f * DELTA;
LIGHT->light.inColor.z -= 0.5f * DELTA;
}
if (INPUT->KeyPress(VK_UP))
{
CAM->position += UP * 300.0f * DELTA;
}
else if (INPUT->KeyPress(VK_DOWN))
{
CAM->position += DOWN * 300.0f * DELTA;
}
if (INPUT->KeyPress(VK_RIGHT))
{
CAM->position += RIGHT * 300.0f * DELTA;
}
else if (INPUT->KeyPress(VK_LEFT))
{
CAM->position += LEFT * 300.0f * DELTA;
}
map->Update();
coin->Update();
}
void Stage02::LateUpdate()
{
}
void Stage02::Render()
{
map->Render();
coin->Render();
}
void Stage02::ResizeScreen()
{
}
코드입니다.
읽어주셔서 감사합니다.
Comments