> 今、↑キーを押すと下に、↓キーを押すと上にボタンオブジェクトが移動するプログラムを作っています。
次のサンプルでどうでしょうか。
#include "User32.as"
//--------------------------------------
// 記号定数(API定数)
//--------------------------------------
#const global NULL 0
#const global SWP_NOSIZE $00000001
#const global SWP_NOZORDER $00000004
#const global SWP_NOOWNERZORDER $00000200
//--------------------------------------
// 仮想キーの列挙定数
//--------------------------------------
#enum VK_LEFT=$25
#enum VK_UP
#enum VK_RIGHT
#enum VK_DOWN
//--------------------------------------
// メイン部
//--------------------------------------
*Init
x=100
y=100
onkey gosub *OnKeyBoard
*Main
color:boxf
pos x,y:button gosub "終了",*PushQuit
stop
*PushQuit
end
*OnKeyBoard
if(wParam==VK_LEFT) :title "←":x+=12
if(wParam==VK_RIGHT) :title "→":x-=12
if(wParam==VK_UP) :title "↑":y+=12
if(wParam==VK_DOWN) :title "↓":y-=12
SetWindowPos objinfo_hwnd(0),NULL,x,y,0,0,(SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER)
return
ボタンの移動はウインドウの移動と同じになります。
また、clrobj命令は描画ではなく配置されたオブジェクトを削除する命令です。