Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Classes and calling parent methods — Gideros Forum

Classes and calling parent methods

seppseppseppsepp Member
edited October 2013 in General questions
Hi.

Following, simple scenario. I've written a class deriving from Sprite meaning to be a base class for different progress bars. Then another class inherits ProgressBar. Weird thing: Even when MegaProgressBar has its own draw() method then the parents draw() gets called too - before the MegaProgressBar:draw()? Seems to be a bug don't you think? This behaviour makes it impossible to override methods =| .


Greetings

Sebastian

Comments

  • Oh, just noticed that the behaviour is only the case when draw() gets called from within init(). Hm, probably I should move that call somewhere else...
  • MellsMells Guru
    edited October 2013
    postInit() might be what you are looking for (sorry no time to provide links!) lot of infos on the forums.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2013
    Made this test and it works as expected:
    Test = Core.class(Sprite)
     
    function Test:test()
    	print("from Test")
    end
     
    SubTest = Core.class(Test)
     
    function SubTest:init()
    	self:test()
    end
     
    function SubTest:test()
    	print("from SubTest")
    end
     
    SubTest.new()
    prints from SubTest

    So the problem is somewhere else :)
  • edited October 2013
    @seppsepp and from SubTest in @ar2rsawseen post above, if you want to call parent method, you can use
    function SubTest:test()
    	print("from SubTest")
    	Test.test(self)
    end
    (use parent class name and . symbol and self, not : symbol)
    Detail link here :)
    https://docs.google.com/document/pub?id=149g_P1YlE4_6v_hHbFx3YAaYpdU0HoM70XJSLTE38ww#h.dzhuvffcwl5a
    Coming soon
Sign In or Register to comment.