画像の移動(blit)

画像の移動(blit)の描画のサンプルです。

構文 screen.blit(screen, x, y, image, [, sourcex, sourcey] [, width, height])

-- blit     blit.lua
 
img = Image.load("ball.png", VRAM)
 
x = (256 /2)  - (32 / 2) -- (X画面の中心) - (ボールの中心) = X画面の中心
y = (198 / 2) - (32 / 2) -- (Y画面の中心) - (ボールの中心) = Y画面の中心
moveY = 2  -- 最初は下に2
 
while not Keys.newPress.Start do
 
	Controls.read()
 
	y = y + moveY -- ボールの位置y座標(xは移動しません)
	if y <= 0 then moveY = 2 end		-- 上にぶつかると下方向へ
	if y >= 198-32 then moveY = -2 end	-- 上のぶつかると上方向へ
 
	startDrawing()
 
	screen.blit(SCREEN_DOWN, x, y, img)	-- ボールの描画
 
	screen.print(SCREEN_UP, 80, 8, "Press START to quit")
	screen.print(SCREEN_UP, 80, 24, "x=" .. x)
	screen.print(SCREEN_UP, 80, 36, "y=" .. y)
	screen.print(SCREEN_UP, 80, 80, "FPS: "..NB_FPS)
	screen.drawRect(SCREEN_DOWN, 0, 0, 256, 192, Color.new(31,31, 31)) -- 白(ホワイト)
 
	stopDrawing()
 
end
 
Image.destroy(img)
img = nil
x = nil
y = nil
moveY = nil
 

実行例
画像の移動(blit)の描画のサンプルです。

画像の移動(blit)の描画のサンプルに使用されている部品です。
背景は、透過処理しています。

タグ:

+ タグ編集
  • タグ:
最終更新:2010年10月27日 12:14
ツールボックス

下から選んでください:

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