6. 文字を表示する。

文字を表示するにはDrawString関数を使います。表示させたい文字列の左上の座標(x,y)に文字列Stringを
表示させたい場合は
DrawString( x , y , *String , Color_Flag);
となります。
Color_Flagについては5節で説明した通りです。
では
(0,0)に「hello! DX Library!」
(100,100)に「こんにちは! DXライブラリ!」
と表示させてみましょう。

↓コピー&コンパイル用サンプルプログラム↓


#include "DxLib.h"
 
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
        ChangeWindowMode( TRUE ) ; // ウインドウモードに変更
        if( DxLib_Init() == -1 ) return -1; // DXライブラリ初期化処理 エラーが起きたら終了 
 
 
        int White;
        White   = GetColor( 255 , 255 , 255 ) ; // 白色の値を取得
 
        DrawString(  0,  0, "hello! DX Library!" , White);            //文字列表示
        DrawString(100,100, "こんにちは! DXライブラリ!" , White);//文字列表示
 
 
        WaitKey() ;                     // キーの入力待ち(『WaitKey』を使用)
        DxLib_End() ;                   // DXライブラリ使用の終了処理
        return 0 ;                      // ソフトの終了
}

実行結果

→掲示板で質問する



- Remical Soft -