我正在使用 DragonRuby Game Toolkit 来构建游戏。
如何检测一个物体(例如 a)是否Sprite与另一个物体发生碰撞Sprite?
这是放置在屏幕上的两个精灵。关于如何检查碰撞的待办事项:
def tick args
# create a sprite
args.state.sprite_one = { x: 100,
y: 200,
w: 50,
h: 50 }
# create another sprite that definitely collides
args.state.sprite_two = { x: 101,
y: 201,
w: 1,
h: 1 }
sprites_collide = ????? # help
if sprites_collide
args.gtk.notify! "sprites collide!"
else
args.gtk.notify! "sprites do not collide!"
end
end
Run Code Online (Sandbox Code Playgroud)