I know that I can add new methods for existing classes in init.lua.
But how do I make that all objects be created with anchor point (0.5, 0.5) ?
I thought in overwrite the Sprite:init method in order to make it call Sprite:setAnchorPosition(0.5, 0.5) but I'm not finding the script Lua that contains Sprite definition.
Note: If you have better idea on how to do it, please let me know.
However you can still do it by overriding 'new' method:
Anyway setAnchorPoint in Sprite is a shorthand for setAnchorPoisition(width*ratio,height*ratio), and since width and height would have been 0 at that time, this wouldn't done anything useful...
EDIT: There may be a way using postInit method. if postInit exists on an object, thehn it is called right after the object is contructed/initialized. So doing:
Likes: SinisterSoft, MoKaLux
I see. Just a question: is it save to create the postInit() in Sprite? I mean, won't it overwrite and postInit() function in a derived class?
I think probably no Sprite's derived class have postInit() but its safer to ask.
мій блог по гідерос https://simartinfo.blogspot.com
I think its better changing code in a specific point that applies to all classes.
@hgy29 Thanks for clarification. I'll add the postInit(...) to Sprite class in init.lua.