On Tue, Feb 3, 2009 at 5:27 PM, Lucio Torre <[email protected]> wrote:
> Why not? cocos comes with some graphic files that are needed for some
> of the modules to work.
> How can we do this if we dont put that package path into the resource path?
The problem isn't only adding the package path to resource path, but
also that later the standard way to create an image is by doing
myImage = pyglet.resource.image(...)
we can change all of those calls for calls to
myImage = pyglet.image.load(...)
but we'd be losing the automatic caching, atlas tiling, flipping and
rotation that the resource module provides.
Btw, it's not only the particle and draw modules that would need to be
changed, but also the menu (for ImageMenuItems), tiles (for, erm,
everything, it seems? :) ), and sprite modules.
We could also just remove the calls to pyglet.resource from our
__init__.py, and let the user fix his own resource path. This way the
app would postpone the freeze for later on, when we tried to create
our first image.
Or, the following dirty hack fixes the problem here (add these lines
at the begining of our __init__.py file, right after the "import sys,
os, pyglet" line):
if 'PYTHONSTARTUP' in os.environ:
pythonrc = os.environ['PYTHONSTARTUP']
main = sys.modules['__main__']
if hasattr(main, '__file__') and main.__file__ == pythonrc:
del main.__file__
I have *no idea* how much this will break elsewhere.
Or, instead, we could add the following lines at the beginning of
Cocos' [1] __init__.py file :)
if hasattr(sys, 'ps1'):
print """ You seem to be running Python in an interactive session.
If importing Cocos takes an unreasonable amount of time, try unsetting your
PYTHONSTARTUP environment variable, or moving your $PYTHONSTARTUP file to a
directory of its own."""
Oh so lazy,
--
Anthony Lenton
[1] Hey, this time I got it right!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---