On Sat, Apr 6, 2013 at 12:30 PM, Doug Linder <[email protected]>wrote:
> Hey there, > > I've been using pywidget (https://pywidget.googlecode.com/svn/trunk) with > cocos2d quite successfully as a GUI, but in order to do so I've had to hack > the cocos director class. > > Basically, modifying Director::on_draw to read, at the end: > > # Draw the GUI > if self.gui != None: > self.gui.on_draw() > > Where you pass in the appropriate pywidget gui object by assigning it to > the director: > > class Client: > def run(self): > > cocos.director.director.init() > cocos.director.director.gui = dialog > cocos.director.director.window.push_handlers(dialog) > > ui = rpg.ui.Test() > main_scene = cocos.scene.Scene (ui) > cocos.director.director.run (main_scene) > > This seems fairly successful in that the cocos event handlers still work, > and the event bindings for the UI work, so all in all, pretty good. > > However, it's annoying having to patch the cocos source to do this. > > I feel like I should just be able to extend CocosNode and override the > draw() method, then add the object to the scene, but my draw() function > never seems to get called when I do this. > > If you subclass CocosNode , instantiate your subclass and adds to an active scene, then his visit and draw methods will be called [0]. If you show code for your CocosNode attempt that is not working for you maybe a fix can be suggested. > Is there some special magic I need to do? > > I don't think so > I'd prefer not to hack up the source just to have a gui if I can avoid it. > > Yeah. Pastebin your original attemp (not modifyng director) , or a simplified one and w'ill see. [0] Technically your overriden visit can decide to skip calls to draw, drawing the node and childs with custom code, presumably for performance reasons. -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cocos-discuss?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
