On Oct 22, 2:00 am, karan <[email protected]> wrote: > On Sep 29, 1:38 am, Devon Scott-Tunkin <[email protected]> > wrote: > > > > > r['level1'] should already be a RectMapLayer class. I think there's a > > bug with the version of cocos you are using. Try using cocos 0.3 or > > the one in the cocograph folder for now (running your program from the > > cocograph folder or copying the cocos folder to your program > > directory). If you are using the latest svn try submitting a bug > > report. > > > Cocograph does still have a few bugs too (I'm the author, btw, thanks > > for trying it out!), but I think this is a cocos related error, > > especially if the map loads fine in cocograph. I've been busy lately > > but I should have a new release of cocograph in a few weeks. > > > On Sep 24, 6:45 pm, karan <[email protected]> wrote: > > > > Hi, I'm using a tile editor called cocograph which creates a map and > > > produces the xml file. I made a map, of size 640 X 480 pixels and > > > loaded it using this: > > > > import cocos > > > from cocos.director import * > > > from cocos import tiles > > > > r = tiles.load('hell.xml') > > > > scene = cocos.scene.Scene(r['level1']) > > > director.init() > > > director.run(scene) > > > > However, it gave me the following error: > > > > Traceback (most recent call last): > > > File "m.py", line 7, in <module> > > > r = tiles.load('hell.xml') > > > File "/home/karan/just/src/cocos/tiles.py", line 315, in load > > > obj = Resource(filename, paths) > > > File "/home/karan/just/src/cocos/tiles.py", line 200, in __init__ > > > self.handle(root) > > > File "/home/karan/just/src/cocos/tiles.py", line 236, in handle > > > return self.factories[tag.tag](self, tag) > > > File "/home/karan/just/src/cocos/tiles.py", line 215, in > > > resource_factory > > > self.handle(child) > > > File "/home/karan/just/src/cocos/tiles.py", line 236, in handle > > > return self.factories[tag.tag](self, tag) > > > File "/home/karan/just/src/cocos/tiles.py", line 498, in > > > rectmap_factory > > > m = RectMapLayer(id, width, height, cells, origin) > > > File "/home/karan/just/src/cocos/tiles.py", line 673, in __init__ > > > super(RectMapLayer, self).__init__() > > > File "/home/karan/just/src/cocos/tiles.py", line 586, in __init__ > > > super(MapLayer, self).__init__() > > > File "/home/karan/just/src/cocos/tiles.py", line 547, in __init__ > > > super(ScrollableLayer,self).__init__() > > > File "/home/karan/just/src/cocos/layer/base_layers.py", line 59, in > > > __init__ > > > super( Layer, self ).__init__() > > > File "/home/karan/just/src/cocos/cocosnode.py", line 111, in > > > __init__ > > > self.camera = Camera() > > > File "/home/karan/just/src/cocos/camera.py", line 55, in __init__ > > > self.restore() > > > File "/home/karan/just/src/cocos/camera.py", line 75, in restore > > > width, height = director.get_window_size() > > > File "/home/karan/just/src/cocos/director.py", line 383, in > > > get_window_size > > > return ( self._window_original_width, > > > self._window_original_height) > > > AttributeError: 'Director' object has no attribute > > > '_window_original_width' > > > > What could be causing the problem ? Is it necessary to create a > > > RectMapLayer class? > > Ok, I tried the following codes, and it still gave errors. I replaced > my copy of cocos with the cocograph one. Could you let me know where > I'm going wrong? > > Code 1: > import cocos > from cocos.director import * > from cocos import tiles > > class hello(cocos.tiles.RectMapLayer): > def __init__(self): > super(hello, self).__init__() > > r = tiles.load('hell.xml') > > r['level1'] = hello() > scene = cocos.scene.Scene(r['level1']) > director.init() > director.run(scene) > > Error: > Traceback (most recent call last): > File "test.py", line 10, in <module> > r = tiles.load('hell.xml') > File "/home/karan/just/src/cocos/tiles.py", line 363, in load > obj = Resource(filename) > File "/home/karan/just/src/cocos/tiles.py", line 254, in __init__ > self.handle(root) > File "/home/karan/just/src/cocos/tiles.py", line 286, in handle > return self.factories[tag.tag](self, tag) > File "/home/karan/just/src/cocos/tiles.py", line 266, in > resource_factory > self.handle(child) > File "/home/karan/just/src/cocos/tiles.py", line 286, in handle > return self.factories[tag.tag](self, tag) > File "/home/karan/just/src/cocos/tiles.py", line 545, in > rectmap_factory > m = RectMapLayer(id, width, height, cells, origin, properties) > File "/home/karan/just/src/cocos/tiles.py", line 842, in __init__ > MapLayer.__init__(self, properties) > File "/home/karan/just/src/cocos/tiles.py", line 640, in __init__ > super(MapLayer, self).__init__() > File "/home/karan/just/src/cocos/tiles.py", line 595, in __init__ > super(ScrollableLayer,self).__init__() > File "/home/karan/just/src/cocos/layer/base_layers.py", line 59, in > __init__ > super( Layer, self ).__init__() > File "/home/karan/just/src/cocos/cocosnode.py", line 111, in > __init__ > self.camera = Camera() > File "/home/karan/just/src/cocos/camera.py", line 55, in __init__ > self.restore() > File "/home/karan/just/src/cocos/camera.py", line 75, in restore > width, height = director.get_window_size() > File "/home/karan/just/src/cocos/director.py", line 392, in > get_window_size > return ( self._window_original_width, > self._window_original_height) > AttributeError: 'Director' object has no attribute > '_window_original_width' > > Code 2: > File Edit Options Buffers Tools Python > Help > import cocos > from cocos.director import * > import pyglet > from pyglet.window import key > from cocos import tiles > > director.init(width = 640, height = 480, do_not_scale = True) > > class sp(cocos.tiles.RectMapLayer): > def __init__(self): > super(sp, self).__init__(22, 2, 222, 255) > > test_layer = tiles.load('hell.xml')['level1'] > self.add(test_layer) > > scene = cocos.scene.Scene(sp()) > director.run(scene) > > Error: > Traceback (most recent call last): > File "m.py", line 18, in <module> > scene = cocos.scene.Scene(sp()) > File "m.py", line 12, in __init__ > super(sp, self).__init__(22, 2, 222, 255) > File "/home/karan/just/src/cocos/tiles.py", line 841, in __init__ > RectMap.__init__(self, id, tw, th, cells, origin, properties) > File "/home/karan/just/src/cocos/tiles.py", line 771, in __init__ > self.px_width = len(cells) * tw > TypeError: object of type 'int' has no len()
bump -- 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=.
