简体   繁体   English

Javascript 函数和子/父继承

[英]Javascript functions and child/parent inheritance

Im not sure if this is an allowed question but i beleive it comes under 'software tools commonly used by programmers;我不确定这是否是一个允许的问题,但我相信它属于“程序员常用的软件工具”; and is a practical, answerable problem that is unique to software development'.并且是一个实用的、可回答的问题,是软件开发所独有的”。 So would someone be able to explain to me how the child and parent prototypes work in javascript preferrably with an example for implementatipon or code example.因此,有人能够向我解释子原型和父原型如何在 javascript 中工作,最好是使用一个实现示例或代码示例。 Speciffically:具体来说:

  1. How to layout parent constructors and methods如何布局父构造函数和方法

  2. How to layout child constructors and methods如何布局子构造函数和方法

  3. How to link a child method to a parent method如何将子方法链接到父方法

  4. How to reference the parent method from the child method如何从子方法引用父方法

  5. What would be a practical implementation of this.这将是一个实际的实现。

    I was thinking of creating a powerup class for my game and then creating Child classes for say a forcefeild, a speed booster ect我正在考虑为我的游戏创建一个增强类,然后创建 Child 类,例如 forcefeild、速度助推器等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM