如何引用单个类的多个实例?
所以我知道如何使用 MovieClip(root).objectName 来定位特定实例,我认为无论如何引用它都是令人讨厌的方式,但现在我正在尝试制作一个格斗简笔画游戏,我只能引用我的代码现在使用“敌人”类对一个 NPC 进行攻击,但如果我可以使用敌人类一次生成多个 NPC,并以敌人类而不是实例本身为目标,同时仍使 NPC 实例保持唯一,那么我希望这样打他们一个不要全部被击中。
So I know how to target a specific instance using MovieClip(root).objectName which I think is nasty way of referring to it anyways, but right now I'm trying to make a fighting stick-figure game and I can only refer my code to one NPC right now using an "enemy" class but I would like it if I could spawn multiple NPC's at once using the enemy class and instead target the enemy class instead of the instance itself while still having the NPC instances being unique so when I hit one they don't all get hit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为你的敌人类别创建一个数组,如下所示:
NPCArray = [];
那么当您想要更新它们时:
我建议您阅读本教程,它解释了 AS3 游戏开发的基础。 http://gamedev.michaeljameswilliams.com/2008/09/ 17/avoider-game-tutorial-1/
create an array for your enemy class, like this:
NPCArray = [];
then when you want to update them all:
I would recommend reading this tutorial, that explains the basis of AS3 game development. http://gamedev.michaeljameswilliams.com/2008/09/17/avoider-game-tutorial-1/