It looks like you're new here. If you want to get involved, click one of these buttons!
Parts = gideros.class(Sprite) Parts.position = {x = 0, y = 0} function Parts:init() end -------------------------------------------- Head = gideros.class(Parts)--Parts is something I define myself function Head:init() end -------------------------------------------- local test = Head.new() print(test.position.x) --prints 0 |
Comments
At first I think that init functions may not be called correctly, but they're called and with the correct order (first Parts:init, then Head:init)
After doing more tests, I will update the documentation
Thank you,
@atilim: I need this too. So, can I use that way officially ? Did you update documents?
Thank Mumujar!
Thank you,
Likes: chipster123, phongtt
--------------------------------------------
--File1.lua
--------------------------------------------
--File2.lua
--------------------------------------------
--File3.lua
--------------------------------------------
File 1:
It's been a long day so I'm probably missing something obvious here.
http://www.giderosmobile.com/documentation/classes_in_gideros.html, as you can inherit from your own classes(?):
Core.class function is used to create your own classes through inheritance. You can only inherit from Gideros API’s own classes (EventDispathcher, Sprite, etc.) and you cannot inherit from your own classes.
For example, you can create your EventDispathcher class like:
MyEventDispathcher = Core.class(EventDispathcher)
Also Dispatcher's spelled wrong.
I've changed all "*Dispathcher"s to "*Dispatcher" and updated the documentation.
Thank you
There's duplicate Gideros documentation in under the Gideros Academy links and in the Ultimate Guide to Gideros and both and aren't always updated. For example:
* The document about classes under Gideros Academy isn't correct regarding inheritance from user classes.
* The document in the Ultimate Guide to Gideros still has the dispatcher spelled incorrectly (well, it did ... I corrected it).
A suggestion: change pointers in Gideros Academy so that they point into the Ultimate Guide to Gideros (where appropriate) so you don't have to maintain two copies of the same information.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Regards
---------------------------------------
postInit is called after init method upon creation.
So you can define in parent class to do something in postInit and then redefine the postInit method in child class.
Here is a reference to the thread about postInit http://www.giderosmobile.com/forum/discussion/2506/is-it-possible-to-call-subclasss-overwrited-function-in-baseclasss-init-function/p1
Likes: Cyberience