I'm trying to create a ImageMenuItem based menu. The code is to belong in a 
map editor (expect more questions in the future)

Here is the code:

class tile_menu(Menu):
    def __init__(self):
        super( tile_menu, self ).__init__()
        
        img = pyglet.image.load('images/map_sprites.png')
        
        tileset = pyglet.image.ImageGrid(img, 3, 15, 96, 96)

        items = list()
        menu_positions = list()
        
        x, y = 0, 0
        
        for i in range(3):
            for j in range(3):
                
                i = ImageMenuItem(tileset[1], self.on_image_callback)
                
                menu_positions.append((x, y))
                
                items.append(i) 
                
                x += 96
            y += 96
            x = 0
        
        self.create_menu( items, selected_effect=None,
                          unselected_effect=None,
                          layout_strategy=fixedPositionMenuLayout(
                            menu_positions))

I get this error:
...snip...
  File "C:\Users\Pittler\Desktop\Dev\mapeditor.py", line 38, in __init__
    i = ImageMenuItem(tileset[1], self.on_image_callback)
  File 
"C:\Python27\lib\site-packages\cocos2d-0.5.5-py2.7.egg\cocos\menu.py", line 
521, in __init__
    self.image = pyglet.resource.image (name)
  File "C:\Python27\lib\site-packages\pyglet\resource.py", line 510, in 
image
    atlas=atlas)
  File "C:\Python27\lib\site-packages\pyglet\resource.py", line 443, in 
_alloc_image
    file = self.file(name)
  File "C:\Python27\lib\site-packages\pyglet\resource.py", line 399, in file
    raise ResourceNotFoundException(name)
pyglet.resource.ResourceNotFoundException: Resource "<ImageDataRegion 
96x96>" was not found on the path.  Ensure that the filename has the 
correct captialisation.

The problem seems to be related to finding the image "resource". This code 
is based upon the same as in my previous thread: 
https://groups.google.com/forum/?fromgroups#!topic/cocos-discuss/X0yoqeMTqK0 , 
where pyglet / cocos did not have this error. So am I doing something wrong 
in ImageMenuItem, or something else?

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to