Hello. 
When i work on my game, i try to use A*, and in a moment start to refactor 
tiles.py :)
First of all, i merge changes 
of  https://github.com/los-cocos/cocos/pull/304, so my refactoring based on 
this.
Commonly, i split code of `load_tmx` to "screen-fitting" size function and 
this refactor has fix some issues with loading.
For example, with next map(created with Tiled), that has separated tileset 
file can't be loaded. It's crash with "UnboundLocalError: local variable 
'tileset' referenced before assignment".
I attach all that needed to reproduce this:
1. put *.png, *.tsx, *.tmx in directory assets in test-root
2. put testing.py in test-root
3. create env, install cocos2d(0.6.5+)
4. run "python testing.py"

In my case, it's files on Koraken branch "tiles-301", and origin versions 
"0.6.6", "0.6.5". 

I'm check utests, but no changes. 18 fails as was before my changes. Looks 
like there is no tests for loading tiled maps :). I'm going to write tests 
in future.

So , changes lie in my fork, i create PR from dev to master for easy 
review. I will be very grateful for the review. 

Best regards.

-- 
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 https://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.

Attachment: tiles.tsx
Description: Binary data

Attachment: untitled.tmx
Description: Binary data

from cocos.tiles import load
from cocos.director import director

director.init(width=1, height=1, autoscale=False, resizable=False)
map_ = load('assets/untitled.tmx')

path_layer = map_['pathes']
for i in range(80):
    for j in range(80):
        cell = path_layer.get_cell(i, j)
        if cell:
            if len(list(cell.tile.properties.keys())) > 0:
                print(f"cell({i}, {j}) tile: {cell.tile}")

Reply via email to