我看了一下源码,Layout对象有一个affectedByScale,当这个属性在编辑中改变时,会调用notify的_doLayoutDirty函数。
我想请教一下,这种方法在typescript里面怎么写呢。就是我想在typescript中定义一个属性,然后在编辑器修改的时候,能调用到这个属性对应的象的某个函数,请教。谢谢。
var Layout = cc.Class({
name: ‘cc.Layout’,
extends: require(’./CCComponent’),
editor: CC_EDITOR && {
menu: 'i18n:MAIN_MENU.component.ui/Layout',
help: 'i18n:COMPONENT.help_url.layout',
inspector: 'packages://inspector/inspectors/comps/cclayout.js',
executeInEditMode: true,
},
properties: {
affectedByScale: {
default: false,
notify: function () {
// every time you switch this state, the layout will be calculated.
this._doLayoutDirty();
},
animatable: false,
tooltip: CC_DEV && 'i18n:COMPONENT.layout.affected_by_scale'
}
}
}