Pon*_*dle 5 inheritance overriding actionscript-3 getter-setter
我有一个继承自Sprite的类(Wall).
Sprite已经具有width和height属性.但是对于墙,我需要在属性改变时做一些其他额外的计算(确保新的大小不会导致它与任何其他墙重叠).
那么,如何在Wall的宽度设置器中设置从Sprite类继承的width属性?(或者,如果设置宽度,可能还有另一种方法来检查我的边界?)
public override function set width(w:Number):void {
//make sure it is a valid size
//if it is, then set the width of the *Sprite* to w. How?
}
Run Code Online (Sandbox Code Playgroud)
Jua*_*ano 12
super 是你在找什么:
override public function set width(v:Number):void {
if(v > 100) {
super.width = v;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4205 次 |
| 最近记录: |