创建一个coord 属性的get set。
这样写是没问题的:
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
_coord: cc.Vec2 = null;
@property(cc.Vec2)
get coord(): cc.Vec2 {
return this._coord;
}
set coord(cr: cc.Vec2) {
this._coord = cr;
}
}
这样写就不行:
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
_coord: cc.Vec2 = null;
@property(cc.Vec2)
get coord(): cc.Vec2 {
return this._coord;
}
set coord(cr: cc.Vec2) {
let oldCoord = this._coord.clone(); //这
this._coord = cr;
}
}
在Creator中点Create 创建不了属性。
