ボタン押下

 ボタンを押した時のサンプルです。
 Keys.held、Keys.released、Keys.newPressの3つがありますが、サンプルでは、Keys.held、Keys.newPressを使用しています。

-- ボタンの状態 boutons1.lua
 
while not Stylus.doubleClick do
 
 	Controls.read()
 	startDrawing()
 	screen.print(SCREEN_UP, 8 * 2 ,20, "LEFT")
 	screen.print(SCREEN_UP,  8 * 12 ,20, "RIGHT")
 	screen.print(SCREEN_UP,  8 * 3 ,60, "UP")
 	screen.print(SCREEN_UP,  8 * 1 ,80, "<-")
	screen.print(SCREEN_UP,  8 * 4 ,80, "->")
 	screen.print(SCREEN_UP,  8 * 2 ,100, "DOWN")
 	screen.print(SCREEN_UP,  8 * 14 ,60, "X")
	screen.print(SCREEN_UP,  8 * 12 ,80, "Y")
	screen.print(SCREEN_UP,  8 * 16 ,80, "A")
 	screen.print(SCREEN_UP,  8 * 14 ,100, "B")
 	screen.print(SCREEN_UP,  8 * 20 ,120, "START")
	screen.print(SCREEN_UP,  8 * 20 ,140, "SELECT")
 
	screen.print(SCREEN_DOWN,  8 * 6 ,80, "Pen touch Double Click Exit")
 
	if Keys.newPress.L or Keys.held.L then
	 	screen.print(SCREEN_UP, 8 * 2 ,20, "LEFT",Color.new(15,0,0 ))
	end	
	if Keys.newPress.R  or Keys.held.R then
		 	screen.print(SCREEN_UP,  8 * 12 ,20, "RIGHT",Color.new(16,0,0 ))
	end
	if Keys.newPress.Up or Keys.held.Up then
		 	screen.print(SCREEN_UP,  8 * 3 ,60, "UP",Color.new(16,0,0 ))
	end
	if Keys.newPress.Left or Keys.held.Left then
			screen.print(SCREEN_UP,  8 * 1 ,80, "<-",Color.new(16,0,0 ))
	end
	if Keys.newPress.Right or Keys.held.Right then
		screen.print(SCREEN_UP,  8 * 4 ,80, "->",Color.new(16,0,0 ))
	end
	if Keys.newPress.Down or Keys.held.Down then
		screen.print(SCREEN_UP,  8 * 2 ,100, "DOWN",Color.new(16,0,0 ))
	end
	if Keys.newPress.X or Keys.held.X then
		screen.print(SCREEN_UP,  8 * 14 ,60, "X",Color.new(16,0,0 ))
	end	
	if Keys.newPress.Y or Keys.held.Y then
		screen.print(SCREEN_UP,  8 * 12 ,80, "Y",Color.new(16,0,0 ))
	end
	if Keys.newPress.A or Keys.held.A then
		screen.print(SCREEN_UP,  8 * 16 ,80, "A",Color.new(16,0,0 ))
	end
	if Keys.newPress.B or Keys.held.B then
 		screen.print(SCREEN_UP,  8 * 14 ,100, "B",Color.new(16,0,0 ))
	end
	if Keys.newPress.Start or Keys.held.Start then
	 	screen.print(SCREEN_UP,  8 * 20 ,120, "START",Color.new(16,0,0 ))
	end
	if Keys.newPress.Select or Keys.held.Select then
		screen.print(SCREEN_UP,  8 * 20 ,140, "SELECT",Color.new(16,0,0 ))
	end
 
 	stopDrawing()
end
 




タグ:

+ タグ編集
  • タグ:
最終更新:2010年07月19日 13:47
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。