DXライブラリを用いてゲームの作成を行っているのですが、ChangeWindowMode関数でウインドウモードを変更すると、表示していた画像が消えてしまいます。
自分としては、メモリ上からグラフィックを削除しているためだと考えています。
#include "DxLib.h"
class Sample{
private:
int image_bg_handle;
bool tmpmode;
public:
void Init();
void Final();
void Update();
void Draw();
};
int Getkey(int keycode);
int z_keycount = 0;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
SetGraphMode(1280, 720, 16);
ChangeWindowMode(TRUE);
if (DxLib_Init() == -1) return -1;
SetDrawScreen(DX_SCREEN_BACK);
Sample *sa1 = new Sample();
sa1->Init();
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){
sa1->Update();
sa1->Draw();
}
sa1->Final();
delete sa1;
DxLib_End();
return 0;
}
int Getkey(int keycode){
if (CheckHitKey(keycode) == 1) z_keycount++;
else z_keycount = 0;
return z_keycount;
}
void Sample::Init(){
image_bg_handle = LoadGraph("sample.png");
tmpmode = TRUE;
}
void Sample::Final(){
DeleteGraph(image_bg_handle);
}
void Sample::Update(){
if (Getkey(KEY_INPUT_Z)){
tmpmode = !tmpmode;
ChangeWindowMode(tmpmode);
}
}
void Sample::Draw(){
DrawGraph(0, 0, image_bg_handle, TRUE); //消えてしまう
DrawString(0, 0, "test", 0x777777); //こちらは残り続ける
}
何か解決する方法はないでしょうか、よろしくお願いします。