メニュー選択の基本形

メニューの選択等の基本形のサンプルです。

-- Select   Select.lua
-- メニューの選択等の基本形
 
pos = 1		-- 選択位置の初期値
KeyA = false	-- Trueになると終了
 
White = Color.new(31, 31, 31) -- 白(ホワイト)
Yellow = Color.new(31, 31, 0) -- 黄(イエロー) 
 
while not keyA do
 
	Controls.read()
 
 	screen.print(SCREEN_UP, 80 ,80, "Select")
  	screen.print(SCREEN_UP, 130 , 76, "UP")
 	screen.print(SCREEN_UP, 130 ,84, "DOWN")
	screen.print(SCREEN_UP, 100 ,130, "Choice A")
 
	screen.print(SCREEN_DOWN, 100, 32, "SELECT", White)
	screen.print(SCREEN_DOWN, 100, 60 + 1 * 8, "1.12345", Yellow)
	screen.print(SCREEN_DOWN, 100, 60 + 2 * 8, "2.67890", Yellow)
	screen.print(SCREEN_DOWN, 100, 60 + 3 * 8, "3.ABCDE", Yellow)
	screen.print(SCREEN_DOWN, 100, 60 + 4 * 8, "4.abcde", Yellow)
	screen.print(SCREEN_DOWN, 100, 60 + 5 * 8, "5.xyz", Yellow)
 
	if Keys.newPress.Down then	-- Downキーを押された時の処理
		pos = pos +1
		if pos == 6 then
			pos = 5
		end
	elseif Keys.newPress.Up then	-- Upキーを押された時の処理
		pos = pos -1
		if pos == 0 then
			pos = 1
		end
	end
 
	screen.print(SCREEN_DOWN, 90, 60 + pos * 8, "*", White)
 
	if Keys.newPress.A then keyA = true end		-- ボタンAが押されたら終了
							-- posを調べたら位置判明
 
	render()
end
 
keyA = nil
pos = nil
White = nil
Yellow = nil
 

実行例
#ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (select.png)





タグ:

+ タグ編集
  • タグ:
最終更新:2010年12月29日 07:58
ツールボックス

下から選んでください:

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