> DrawStringToHandle(320, 100, "ショット %d", ChangePadNumber, GetColor(255, 255, 255), Shot);
%d のような書式指定を行い、且つフォントハンドルを使用する場合は DrawStringTohandle ではなく
DrawFormatStringToHandle を使用します
// フォントハンドルを使用して書式指定文字列を描画する
int DrawFormatStringToHandle( int x, int y, int Color, int FontHandle, char *FormatString, ... ) ;
DrawFormatStringToHandle と DrawStringToHandle では色やフォントハンドルの引数の順番が異なりますので注意してください
カカロットさんが記述された処理を行う場合は以下のようになります
DrawFormatStringToHandle(320, 100, GetColor(255, 255, 255), Shot, "ショット %d", ChangePadNumber);
あと、ご存知かもしれませんがフォントハンドルは作成に時間がかかり、且つ作成できる数も限られていますので
事前に必要なフォントハンドルを作成しておいて、ゲームループ中ではなるべく CreateFontToHandle を使用しないようにしてください m(_ _)m
< 良くない例 ( 毎ループフォントハンドルを作成している >
// メインループ
while( ProcessMessage() == 0 )
{
ClearDrawScreen() ;
int FontHandle = CreateFontToHandle(NULL, 16, 3 );
DrawFormatStringToHandle( 100, 100, GetColor( 255,255,255 ), FontHandle, "Number:%d", 8 ) ;
DeleteFontToHandle( FontHandle ) ;
ScreenFlip() ;
}
< 良い例 ( フォントハンドルは初期化のときなどに作成しておく >
int FontHandle = CreateFontToHandle(NULL, 16, 3 );
// メインループ
while( ProcessMessage() == 0 )
{
ClearDrawScreen() ;
DrawFormatStringToHandle( 100, 100, GetColor( 255,255,255 ), FontHandle, "Number:%d", 8 ) ;
ScreenFlip() ;
}
DeleteFontToHandle( FontHandle ) ;