game.loading do |loader|
loader.add :window, :system => "window"
loader.add :gui_item, :system => "gui_item"
loader.add :human_image, 239
end
# ゲームの初期化
game.on_init do
set_window_image :window
set_gui_image :gui_item
# オープニングのシーンへ
scene_change :start_scene
end
scene :start_scene do |scene|
scene.on_init do
scene.add :image, :name => :human1, :template => :human, :center_position => [450, 16]
# タップすると文章を表示
scene.event :human1, :on_click do
speak "タップすると文章を表示します"
end
end
end
sprite_template :human do |st|
st.texture :human_image
st.src_size 32, 32
st.dest_size 32, 32
st.center_offset 32/2, 32/2
st.motion :default do |commands|
commands.proc_call do |sprite|
sprite.change_animation :down
end
# 座標(384, 209)に4px/frameの速度で移動
commands.move_to_v 384, 209, 4
end
st.animation :default do |c|
c.loop true
c.copy_rect :frame => 16, :src => [0, 0]
c.wait_animation
c.copy_rect :frame => 16, :src => [1, 0]
c.wait_animation
end
# 足踏みを定義する
# 16フレームごとに表示画像を切り替える
st.animation :down do |c|
c.loop true
c.copy_rect :frame => 16, :src => [0, 0]
c.wait_animation
c.copy_rect :frame => 16, :src => [1, 0]
c.wait_animation
end
st.animation :up do |c|
c.loop true
c.copy_rect :frame => 16, :src => [0, 3]
c.wait_animation
c.copy_rect :frame => 16, :src => [1, 3]
c.wait_animation
end
st.animation :left do |c|
c.loop true
c.copy_rect :frame => 16, :src => [0, 1]
c.wait_animation
c.copy_rect :frame => 16, :src => [1, 1]
c.wait_animation
end
st.animation :right do |c|
c.loop true
c.copy_rect :frame => 16, :src => [0, 2]
c.wait_animation
c.copy_rect :frame => 16, :src => [1, 2]
c.wait_animation
end
end