Windowsアプリケーションを作成しています。それで、デバッグすると、DX.LoadGraph("Player.bmp")のところで-1が返ってきて画像が表示できません。Player.bmpのディレクトリは「D:\Mydocument\Visual Studio 2008\Projects\DXTimeLine\joyDevicer\bin\x86\Debug」です。それから、DX.LoadGraph("C\\Player.bmp")として、画像をCドライブに配置しても画像は表示できませんでした。
using System;
using System.Windows.Forms;
using System.Threading;
using DxLibDLL;
namespace Joystick
{
static class WinMain
{
static void func_1()
{
int Key;
int PlayerX, PlayerY;
int PlayerGraph;
DX.ChangeWindowMode(DX.TRUE);
// 描画先画面を裏画面にセット
DX.SetDrawScreen(DX.DX_SCREEN_BACK);
// グラフィックのロード
PlayerGraph = DX.LoadGraph("Player.bmp");
// キャラクターの初期位置をセット
PlayerX = 0;
PlayerY = 0;
// DXライブラリ初期化処理
if (DX.DxLib_Init() == -1)
{
// エラーが起きたら直ちに終了
}
else
{
// ループ
while (DX.ProcessMessage() == 0 &&
DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 0)
{
// キー入力取得
Key = DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1);
// 上を押していたら上に進む
if (Key == DX.PAD_INPUT_UP) PlayerY -= 3;
// 下を押していたら下に進む
if (Key == DX.PAD_INPUT_DOWN) PlayerY += 3;
// 右を押していたら右に進む
if (Key == DX.PAD_INPUT_RIGHT) PlayerX += 3;
// 左を押していたら左に進む
if (Key == DX.PAD_INPUT_LEFT) PlayerX -= 3;
// 画面を初期化する
DX.ClearDrawScreen();
// プレイヤーを描画する
DX.DrawGraph(PlayerX, PlayerY, PlayerGraph, DX.TRUE);
// 裏画面の内容を表画面に反映させる
DX.ScreenFlip();
}
}
// DXライブラリ使用の終了処理
DX.DxLib_End();
}
[STAThread]
static void Main()
{
//二重起動をチェックする
if (System.Diagnostics.Process.GetProcessesByName(
System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
{
// 二重起動防止
}
else
{
try
{
// スレッドの宣言
Thread thread_1 = new Thread(new ThreadStart(func_1));
// スレッドの起動
thread_1.Start();
}
catch { }
}
}
}
}