wrong method gets called....

Monkey Forums/Monkey Bug Reports/wrong method gets called....

slenkar(Posted 2012) [#1]
In my game I have a generic 'gadget' class with an abstract method 'render'

I have gadgets that have their own render methods, e.g. buttons and text gadgets are going to render themselves differently.

When I am making a game and it reaches a certain level of complexity the wrong render method is called

the render method of the generic gadget class is called and not the render method of the button for example.

My game is too big to post any code and I cant reproduce it in a code sample. Im just asking if you could please look over the code that decides which method to call just in case you can spot a bug.

Ive seen this happen in html5 and flash so far


I know its a problem with monkey because usually i call the render method from the base class:
for local i:gadget=eachin gadget_list
i.render()
next

which used to work,

but now it only works when I do :
for local i:gadget=eachin gadget_list
if button(i)
local b:button=button(i)
b.render
else
i.render()
endif
next

which defeats the point of OO when you have to do an IF for every type of gadget (16 gadgets)