如何在corona Sdk中添加激光对火的效果
我已经在 corona SDK 中开始了我的第一个游戏,并涵盖了很多内容,但现在我坚持使用武器的激光功能,不太知道如何实现它。有什么指导吗?我想使用激光发射火焰功能,该功能会对其他粒子产生碰撞效果。提前致谢。
I have started my first game in corona SDK and have covered a lot but now I'm stuck to a laser functionality for the weapons , have not much idea how can I implement this . any guidance please ? I want to throw laser on fire function which have collision effect other particles.Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这是一个相当广泛的问题,所以我只能在高水平上回答这个问题。首先,看看我的示例 OOP 框架,了解在 Lua 中进行面向对象编程的一种方法:
http://developer.anscamobile.com/code/object-orient-sample -game-framework
现在,无论您使用这种方法还是其他技术来实现 OOP,您要做的就是创建一个激光对象,并且每次玩家开火时都会在武器的位置实例化一个激光对象。然后在 Laser 的构造函数中设置一个 EnterFrame 监听器,它将每帧向前移动一点。通过每帧移动一点,激光将平稳地向前移动。
至于碰撞,如果您在游戏中使用物理,那么您可以将激光变成物理对象来以这种方式处理碰撞。或者,您可以使用激光对屏幕上的每个敌人进行简单的距离检查;当激光靠近敌人时,意味着激光击中了该敌人。
Well that is a fairly broad question so I can only answer that on a high level. First off, look at my sample OOP framework for one way to do object oriented programming in Lua:
http://developer.anscamobile.com/code/object-oriented-sample-game-framework
Now whether you use this approach or some other technique to achieve OOP, what you want to do is create a Laser object and every time the player fires instantiate a Laser object at the weapon's position. Then in the Laser's constructor set an enterFrame listener that will move it forward a little bit every frame. By moving a little bit every frame, the laser will smoothly animate forward.
As for collision, if you are using physics in your game then you could make your lasers into physics objects to handle collisions that way. Alternatively, you can do a simple distance check with the laser against every enemy on screen; when the laser is close to an enemy that means the laser hit that enemy.