Post

20Connecting the laser to the level

给玩家增加手表右键/空格键单击时增加发射激光动作,如果激光击中的物体带有hit函数那么调用它表明被攻击了。

一些细节

  • 判断对象是否有某个方法:
    • 1.has_method:obj.has_method(name)
    • 2.in检查对象是否具有属性、方法 name in obj
  • 激光自动销毁
    • 1.激光和其他对象碰撞时消费(queue_free)
    • 2.用计时器timeout来销毁
This post is licensed under CC BY 4.0 by the author.