Hi Paul,
On Thu, May 23, 2013 at 9:58 PM, Paul Pittlerson <[email protected]>wrote: > I wanted to use director as its own class, something like > > class screen(cocos.director.director): > def __init__(self, width, height): > super(screen, self).__init__(width, height) > self.run() > > etc, but that does not seem to work. > This fails for multiple reasons: cocos.director.director is an instance of cocos.director.Director, not a class, so the first line cant work you are mixing the signature of Director.__init__ with the one of Director.init self.run() needs a scene as an argument, you provide nothing. But I think trying to fix these problems is not the way to go. The class cocos.director.Director is not meant to be subclassed nor directly instantiated. In cocos you are meant to obtain a director instance by from cocos.director import director Later, when you want to create the window you do director.init(width, height, ...) (notice is init , not __init__) After this call you can access the associated pyglet window in the member director.window Later, when you want to run your scene: scene = MyScene(...) director.run(scene) Using this style is 'going with the grain', trying to fix the original code is 'going across the grain', you will find multiple problems. > Also, the docs say that director class has the same methods as > pyglet.window.Window, but I don't know how to access them. > I don't think the docs say that, but if you can point a specific paragraph that is not clear I will fix it. If you really need access to the window (it is uncommon in cocos), you will find it in director.window (this director is the same you obtained with from cocos.director import director) > I tried something basic like > > cocos.director.director.set_icon(pyglet.image.load('icon.png') > > But despite the docs basically saying that director is the same as > pyglet.window, it appears to not have the same methods at all. > Look my prev comment You can peek many simple cocos samples in the subdirs 'tests' and 'samples' provided in the source package and the docs zip, that will give you a sense of common usage patterns. -- 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.
