Tiled files

This forum is currently in read-only mode.
From the Asset Store
Human/Character Base Pixel Art Sprites in various poses (nearly 100 files)
  • I added multiple tilesets to this just for the heck of it.

    The sprites with the tilesets need to be named according to the names in the Tiled file, or it won't work.

    from xml.dom import minidom
    #from array import array
    #mapfile = minidom.parse(System.AppPath + 'ConstructTestMap.tmx')
    mapfilename = System.globalvar('TilesetFile')
    Spritename = '';
    mapfile = minidom.parse(System.AppPath + mapfilename)
    a = mapfile.getElementsByTagName('map')[0]
    width = int(a.attributes['width'].value)
    height = int(a.attributes['height'].value)
    tilewidth = int(a.attributes['tilewidth'].value)
    tileheight = int(a.attributes['tileheight'].value)
    TSlook = {}
    #load all tilesets
    for tileset in mapfile.getElementsByTagName('tileset'):
    	tsfirstid = int(tileset.attributes['firstgid'].value)
    	tsname = str(tileset.attributes['name'].value)
    	TSlook[tsname] = tsfirstid
    #load all layers
    for layer in mapfile.getElementsByTagName('layer'):
    	for tile in layer.getElementsByTagName('tile'):
    		val = int(tile.attributes['gid'].value)	
    		if val > 0:
    		# find out what spritesheet to get sprite from.
    			lastchecked = 0
    			for k,v in TSlook.iteritems():
    				if val>=v and lastchecked <v:
    					lastchecked = v
    					Spritename = k
    			Spriteobj = eval('SOL.' + Spritename)
    			if layernum==3:
    			Spriteobj.x = (index % width) * tilewidth
    			Spriteobj.y = (index / width) * tileheight
    			Spriteobj.SetAnimFrame(val - lastchecked + 1)
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm tying to load objects and its values aka properties but I need help

    for group in mapfile.getElementsByTagName ('objectgroup'):
          for obj in group.getElementsByTagName('object'):
               objX = int(obj.attributes['x'].value)
               objY = int(obj.attributes['y'].value)
               System.Create (objName, 'obj', objX, objY )
               newobj = eval('SOL.'+objName)
    #thats all works, problem is here:
               newobj.SetValue ('target', int(obj.properties.attributes['target'].value))

    ('target' is object's test var\property in Tiled)

    Actualy, this last line is random, I have no idea what to do

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)