Getitng Widget modified values: when the widget modified values are available eg. onLoad, onStart (v.1.7) or other!


@slackmoehrle, hi,
Property value modified by the widget (Align widget) could not be found by onLoad or onStart default method of cocos creator. So what is the best way to get the value modified by widget excluding update method. Cause there will be so many calculation in the update method.

Thanks in advance.


Need to see some code.

Sometimes the scope can be lost depending on how you reference you methods.


Thanks for the reply. I am newbie in cocos creator and have certain questions in mind while porting some of my interactive contents to cocos creator. In a scene onLoad->onStart->update(dt) executes one after another. i set widgets to left and right some percentage values. They works fine for different screen resolutions. Based on left artwork i want to place my monkey as seen in the screen for different resolution. like monkey.x = arwork.x + someOffset but both onLoad() and start() unable to get the value changed by widget attached with left artwork. I tested in update(dt) method and i get the result as i expected which i dont want! widget sample

Is there any super() call or something?


It’s hard to tell without any code.

Are you adding event listeners during load or start? And do you try to read value in those event listeners?


align widget is attached with the Left land.
The minimal code that can describe my problem is …

onLoad () { this.monkey.x = },
// Not getting updated values of land

start () { this.monkey.x = },
// update values are not here

update (dt) { this.monkey.x = },
// here i am getting the updated values.


try unchecking Align Once property of widget in your UI in cocos creator, it should do the trick for you.