vlarin
July 26, 2017, 1:42pm
#1
With this simplest property you’ll get empty Component with no visible properties in Cocos Creator. Are there any solutions or that is intended behavior?
@ccclass
export class LetterView extends cc.Component {
@property(cc.Sprite) private _icon: cc.Sprite;
}
nantas
July 27, 2017, 2:34am
#2
It’s intended behavior, property with underscore are hidden.
You can override the behavior with explicitly visible attribute setting:
@property({
type: cc.Sprite,
default: null,
visible: true
})
private _icon: cc.Sprite:
3 Likes
vlarin
July 27, 2017, 7:32am
#3
Have tried it and it works well.
Thanks a lot for a quick response and clarification!
Thanks! I was not aware of that attribute.
how to write this code in typeScript
smoothFollow: false,
followX: {
default: 0,
visible () {
return this.smoothFollow;
}
},
it’s not work
@property({
default: false
})
smoothFollow=false;
@property({
default: false,
visible () {
return this.smoothFollow;
}
})
thanks.
nantas
July 31, 2017, 5:55am
#6
From typescript documentation:
http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/typescript/index.html
@property
_width = 100;
@property
get width () {
return this._width;
}
@property
set width (value) {
cc.log('width changed');
return this._width = value;
}