game.loading do |loader|
loader.add :window, :system => "window"
loader.add :gui_item, :system => "gui_item"
loader.add :ikosami_image, 158
end
#変数関数
Variable = {}
def setVariable(a, b)
Variable[a] = b
end
def getVariable(a)
Variable[a]
end
setVariable(:x, 400)
# ゲームの初期化
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
sp = scene.add :image, :template => :ikosami, :center_position => [0, 0]
sp2 = scene.add :image, :template => :ikosami, :center_position => [400, 0]
speak("表示テスト")
sp.event :on_click do |event|
# モーション変更
x = rand(300)
y = rand(200)
sp.set_position x, y
end
sp2.event :on_click do |event|
# モーション変更
setVariable(:x, getVariable(:x)+20)
if getVariable(:x) > 650
setVariable(:x, 0)
end
sp2.set_position getVariable(:x),0
end
end
end
sprite_template :ikosami do |st|
st.texture :ikosami_image
st.src_size 300, 300
st.dest_size 300, 300
st.center_offset 0, 0
#当たり判定
st.collision :rect, :position => [0, 0], :width => [300, 300]
st.motion :default do |commands|
commands.loop false
commands.proc_call do |sprite|
sprite.change_animation :anim
end
end
st.animation :anim do |commands|
commands.loop true
commands.copy_rect :frame => 6, :src => [0, 0]
commands.wait_animation
commands.copy_rect :frame => 6, :src => [1, 0]
commands.wait_animation
commands.copy_rect :frame => 6, :src => [2, 0]
commands.wait_animation
commands.copy_rect :frame => 6, :src => [3, 0]
commands.wait_animation
commands.copy_rect :frame => 6, :src => [2, 0]
commands.wait_animation
commands.copy_rect :frame => 6, :src => [1, 0]
commands.wait_animation
end
end