On Mon, Apr 23, 2012 at 9:53 AM, trevor donahue <[email protected]>wrote:

> hi guys!
> having a really disturbing issue here
>
> I tried creating a really simple platformers game, inspired by the
> example provided in the test/test_platformer.py from the Downloads
> section.
> I just started using python so maybe i'm missing something trivial
> The example works like a charm it's just that when I try to implement
> it into a class it gives me errors. Here's the code:
> [code]
>
>
>From a quick glance I see two invocations to director.init. Thats not good.
In MainMenu.on_new_game I suggest you do something in the line:

def on_new_game(self):
    scene = new_gamescene()
    director.replace(scene) # or push, if you want to retain the ability to
return to main menu scene from the gamescene

where the function new_gamescene have roughly the stuff in the old
on_new_game, except for the director.init and director.run invocations.

Also, pushing handlers is something best done in on_enter, with matching
remove_handlers in the on_exit, otherwise the handlers will be called even
when the scene is not active

For further feedback, try to post an easy runnable example: the code you
posted
  1. has indentation and line breaks ruined by the travel on mail (attach
the code if it is small, or use a pastebin like http://pastebin.com )
  2. has missing parts (no imports, missing code replaced by ellipsis)
  3. if it need resources, and they are resources in the cocos test
directory, write the paths so that placing the script in that directory
will allow the script to found the resources
  4. if it need custom resources, provide a link to a zip with the custom
resources, with the proper directory layout, so to run the sample all
needed is unzip, cd, run the script.

claudio

--

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to