AS3 - 扩展功能?
我有一个带有 destroy()
函数的实体类。
我还有一个扩展 Entity 的 Enemy 类,并且我想向 destroy()
函数添加一些行。
有没有办法扩展 ActionScript 3 中的功能,或者复制粘贴是可行的方法?谢谢。
I have an Entity class with a destroy()
function.
I also have an Enemy class that extends Entity, and I want to add some lines to the destroy()
function.
Is there a way to extend functions in ActionScript 3, or is copy and paste the way to go? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
override
关键字标记该方法,并从那里使用相同的命名空间(public
、protected
等)和名称,使在要扩展的类中设置要重写的方法。该方法还必须具有相同的返回类型并接受相同的参数
示例覆盖:
如果排除读取
super.destroy()
的行,则基类中的函数将不会运行,并且只会使用您的新代码。You need to mark the method with the
override
keyword, and from there use the same namespace (public
,protected
, etc) and name that make up the method you want to override in the class you're extending.The method must also have the same return type and accept the same arguments
Sample override:
If you exclude the line which reads
super.destroy()
, the function within the base class will not be run, and only your new code will be used instead.