提示コードですがprintf();で変数の中身を確認しているのですがLoadgraph()関数では-1以外が返ってきているためリファレンス通り問題ありません。DrawGraph();関数で"あああああ"が表示されていますつまりDrawGraph();関数で問題が起きているということなのですがこれはなぜでしょうか?リファレンスを確認しまたが引数の指定などは間違えておらず座標の設定も表示画面ないのため描画されるはずです。
ライブラリDrawGraph : https://dxlib.xsrv.jp/function/dxfunc_graph1.html#R3N7
ライブラリLoadGraph : https://dxlib.xsrv.jp/function/dxfunc_graph1.html#R3N2
hpp
1#ifndef ___GAME_HPP 2#define ___GAME_HPP 3#include "glm/glm.hpp" 4#include <array> 5 6#define SCREEN_WIDTH ((int)640) 7#define SCREEN_HEIGHT ((int)480) 8 9//前方宣言 10class Entry; 11class Game 12{ 13public: 14 Game(Entry* entry); 15 ~Game(); 16 17 void Update(); 18 void Draw(); 19 20 21private: 22 23 //スプライト 24 int handle_Player; //プレイヤー 25 26 27 28 29 30 31 Entry* owner; //Entryクラス 32}; 33 34#endif 35
cpp
1#include "Game.hpp" 2#include <iostream> 3#include "DxLib.h" 4 5 6Game::Game(Entry* entry) 7{ 8 owner = entry; //Entry クラス 9 10 handle_Player = 0; 11 int handle_Player = LoadGraph("Assets/test.png"); //プレイヤー 12 printf("%d\n",handle_Player); 13} 14 15 16Game::~Game() 17{ 18 19} 20 21//計算 22void Game::Update() 23{ 24 25} 26 27//描画 28void Game::Draw() 29{ 30 DrawBox(0,0,100,100,GetColor(255,255,255),true); 31 32 if (DrawGraph(100, 100, handle_Player, TRUE) == -1) 33 { 34 printf("あああああああ\n"); 35 } 36} 37
回答1件
あなたの回答
tips
プレビュー