このサンプルでは以下の処理を行っています。
- ログイン画面開始とログインフレーム表示状態をステートで管理
- ログイン画面が開始されたらアニメーションを開始する
- ログインフレームを表示する
- プレイモードの開始、選択中、決定状態をステートで管理
- プレイモードが開始されたらアニメーションを開始する
- プレイモード選択中
- プレイモードが選択されたら決定アニメーションを開始する
- 決定アニメーションが終了したらログイン・プレイモード処理を終了する
ログイン・プレイモード画面用スクリプト
LOGINST_TVANIME = 0;
LOGINST_LOGIN = 1;
g_dwLoginState = LOGINST_TVANIME;
function OnStartLogin()
g_dwLoginState = LOGINST_TVANIME;
hdxMatrixRotationX( 0,hdxToRadian(90) );
hdxLoadModel( 0,"title.x",0 );
hdxLoadAnime( 0,"pm_tvanime.hda",0 );
hdxCtrlAnime( 0,CTRLMODE_AUTO_END,0,0,-1 );
hdxLoadAnime( 1,"pm_playmode.hda",0 );
hdxCtrlAnime( 1,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 2,"pm_cursor.hda",0 );
hdxCtrlAnime( 2,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 3,"pm_finish.hda",10 );
hdxCtrlAnime( 3,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 4,"lighting.hda",0 );
hdxCtrlAnime( 4,CTRLMODE_AUTO_LOOP,0,0,-1 );
hdxLoadAnime( 5,"pm_logo.hda",0 );
hdxCtrlAnime( 5,CTRLMODE_AUTO_LOOP,0,75,-1 );
hdxLoadImage( 0,"pm_image.tga" );
hdxSetPutRange( 0,0,544,384,458,380,0,0 );
hdxSetPutRange( 1,0,544,0,458,380,0,0 );
hdxSetPutRange( 2,0,0,624,224,144,0,0 );
hdxSetPutRange( 3,0,0,472,401,144,0,0 );
hdxSetPutRange( 4,0,0,0,542,464,40,35 );
hdxSetPutRange( 5,0,232,624,148,30,74,15 );
hdxSetPutRange( 6,0,384,624,148,30,74,15 );
hdxSetPutRange( 7,0,232,656,148,30,74,15 );
hdxSetPutRange( 8,0,384,656,148,30,74,15 );
hdxSetPutRange( 9,0,232,688,148,30,74,15 );
hdxSetPutRange( 10,0,384,688,148,30,74,15 );
hdxSetPutRange( 11,0,232,720,148,30,74,15 );
hdxSetPutRange( 12,0,384,720,148,30,74,15 );
hdxLoadSound( 0,"pm_bgm.wav" );
hdxLoadSound( 1,"pm_cursor.wav" );
hdxPlaySound( 0,TRUE );
end
function OnRunLogin( upd_frm )
if( g_dwLoginState==LOGINST_TVANIME ) then
if( hdxIsEndAnime(0)==TRUE ) then
hdxOpenLoginFrame();
g_dwLoginState = LOGINST_LOGIN;
end
end
hdxSetZBuffer( TRUE );
hdxMatrixRotationY( 0, hdxToRadian( ((hdxGetTime()%(360*60))/60) ) );
hdxSetLookAt( 0,0,40, 0,0,0, 0,1,0 );
hdxSetViewport( 0,0,RENDER_WIDTH,RENDER_HEIGHT );
hdxDrawModel( 0,0 );
hdxSetZBuffer( FALSE );
hdxDrawAnime( 4, 0, 0, 1.0, 1.0 );
hdxDrawAnime( 0, 640, 360, 1.0, 1.0 );
hdxDrawAnime( 5, 0, 0, 1.0, 1.0 );
hdxDrawLoginFrame( 0xA689FF );
end
PMST_OPEN = 0;
PMST_SELECT = 1;
PMST_END = 2;
g_dwPMState = PMST_OPEN;
g_dwPMSelect = 0;
function OnStartPlayMode( login,pmode )
trace( "OnStartPlayMode : "..login..","..pmode );
g_dwPMSelect = pmode;
g_dwPMState = PMST_OPEN;
hdxCtrlAnime( 1,CTRLMODE_AUTO_END,0,0,-1 );
hdxCtrlAnime( 2,CTRLMODE_AUTO_END,0,0,30 );
end
function OnRunPlayMode( upd_frm )
if( g_dwPMState==PMST_OPEN ) then
if( hdxIsEndAnime(1)==TRUE and hdxIsEndAnime(2)==TRUE ) then
trace( "プレイモード選択許可" );
hdxEnablePlayMode();
g_dwPMState = PMST_SELECT;
end
elseif( g_dwPMState==PMST_SELECT ) then
elseif( g_dwPMState==PMST_END ) then
if( hdxIsEndAnime(3)==TRUE ) then
trace( "プレイモード終了" );
hdxNextScene();
end
else
end
hdxSetZBuffer( TRUE );
hdxMatrixRotationY( 0, hdxToRadian( ((hdxGetTime()%(360*60))/60) ) );
hdxSetLookAt( 0,0,40, 0,0,0, 0,1,0 );
hdxSetViewport( 0,0,RENDER_WIDTH,RENDER_HEIGHT );
hdxDrawModel( 0,0 );
hdxSetZBuffer( FALSE );
hdxDrawAnime( 4, 0, 0, 1.0, 1.0 );
hdxDrawAnime( 0, 640, 360, 1.0, 1.0 );
hdxDrawAnime( 5, 0, 0, 1.0, 1.0 );
hdxDrawLoginFrame( 0xA689FF );
hdxDrawAnime( 1, 0, 0, 1.0, 1.0 );
hdxDrawAnime2( 2, 0, 0, 1.0, 1.0, "_pmCursorDraw" );
hdxDrawAnime( 3, 0, 0, 1.0, 1.0 );
end
function _pmCursorDraw( layer,x,y,frm_x,frm_y,frm_sx,frm_sy,frm_alpha,frm_rot )
if( layer==0 ) then
local _x = frm_x + x;
local _y = frm_y + y;
hdxPut( 0,_x,_y );
local game_mode = hdxIsSupportedGameMode();
if( game_mode["standard"]==TRUE ) then hdxPut( 9,150+_x,291+_y ); else hdxPut( 5,150+_x,291+_y ); end
if( game_mode["expert"]==TRUE ) then hdxPut( 10,307+_x,291+_y ); else hdxPut( 6,307+_x,291+_y ); end
if( game_mode["class"]==TRUE ) then hdxPut( 11,150+_x,326+_y ); else hdxPut( 7,150+_x,326+_y ); end
if( game_mode["free"]==TRUE ) then hdxPut( 12,307+_x,326+_y ); else hdxPut( 8,307+_x,326+_y ); end
if( g_dwPMSelect==0 or g_dwPMSelect==1 ) then
hdxSetBlendMode( BLEND_ADD );
if( g_dwPMSelect==0 ) then
hdxSetPutStatus( 2, math.sin((hdxGetTime()%900)/2.5*math.pi/180)/8+0.4,1,1,0 );
hdxPut( 2,_x+29,_y+116 );
else
hdxSetPutStatus( 2, math.sin((hdxGetTime()%900)/2.5*math.pi/180)/8+0.4,1,1,0 );
hdxPut( 2,_x+205,_y+116 );
end
hdxSetPutStatus( 4, math.sin((hdxGetTime()%900)/2.5*math.pi/180)/8+0.4,1,1,0 );
hdxPut( 4,_x,_y );
hdxSetBlendMode( BLEND_NORMAL );
end
return TRUE;
elseif( layer==1 ) then
local _x = frm_x + x;
local _y = frm_y + y;
hdxPut( 1,_x,_y );
local game_mode = hdxIsSupportedGameMode();
if( game_mode["standard"]==TRUE ) then hdxPut( 9,150+_x,291+_y ); else hdxPut( 5,150+_x,291+_y ); end
if( game_mode["expert"]==TRUE ) then hdxPut( 10,307+_x,291+_y ); else hdxPut( 6,307+_x,291+_y ); end
if( game_mode["class"]==TRUE ) then hdxPut( 11,150+_x,326+_y ); else hdxPut( 7,150+_x,326+_y ); end
if( game_mode["free"]==TRUE ) then hdxPut( 12,307+_x,326+_y ); else hdxPut( 8,307+_x,326+_y ); end
if( g_dwPMSelect==2 ) then
hdxSetBlendMode( BLEND_ADD );
hdxSetPutStatus( 3, math.sin((hdxGetTime()%900)/2.5*math.pi/180)/8+0.4,1,1,0 );
hdxPut( 3,_x+28,_y+116 );
hdxSetPutStatus( 4, math.sin((hdxGetTime()%900)/2.5*math.pi/180)/8+0.4,1,1,0 );
hdxPut( 4,_x,_y );
hdxSetBlendMode( BLEND_NORMAL );
end
return TRUE;
end
return FALSE;
end
function OnChangePlayMode( pmode )
g_dwPMSelect = pmode;
hdxPlaySound( 1,FALSE );
end
function OnEndPlayMode( pmode )
g_dwPMSelect = pmode;
hdxStopSound( 0 );
hdxCtrlAnime( 3,CTRLMODE_AUTO_END,0,0,-1 );
g_dwPMState = PMST_END;
end