i made some amends… i dont know if it’s right or wrong but i thought maybe it’s better to have one spriteSet per layer eg
then again that wouldn’t allow for animated tiles
actually it probably doesnt make any difference… it’s all just coming from one bitmap anyway isnt it. I was thinking the spriteSet created a separate texture on the GPU whereas it’s probably just a table of indices
[lua]-- ORIGINAL
–self = sprite.newSprite( tileSet.spriteSets[0 + dataBackup.gid] )
–AMEND.
– one set with multiple tiles
self = sprite.newSprite(tileSet.spriteSets[1])
self.currentFrame=0+dataBackup.gid[/lua]
and
[lua]-- ORIGINAL
–for i=1, self.tileCount, 1 do
– self.spriteSets[i] = sprite.newSpriteSet(self.spriteSheet, i, 1)
–end
Ah ha, currentFrame is exactly what I was looking for so thank you for that I have added that in and will hopefully get multiple tilesets working tomorrow. I also want to take a look at getting object layers working as that looks pretty cool.
Nite nite (this time for real ), any more comments, updates etc just post them here or email them to me on my site and I will look at them when I get up. [import]uid: 5833 topic_id: 3534 reply_id: 10837[/import]
I’m trying to get each layer to get each TMX layer to be a displayGroup however when I do so I just get a black screen, I have uploaded the code here and if you (or anyone else) could take a quick look at it that would be great.
The layer group is created on line 192 of lime (originally it was just a table) and on line 278 I insert it into the map group and on line 121 I insert the tile sprite into the layer group.
Commenting out lines 278 and 121 (and commenting back in line 311) plus changing 192 back to a standard table will allow the map to be drawn.
The plan is that when layers are all groups you can just call map:getLayer(layerName) in order to insert things like enemies on specific levels, for example line 15 of main.lua which which will need to be commented back out like the other lines if you want to see the map loading without layers working properly. [import]uid: 5833 topic_id: 3534 reply_id: 10858[/import]
Version 0.4 is up, object layers (and object properties) are now working.
I need to write some helper functions to ease the access to things like objects and properties but at least it is all being imported properly. [import]uid: 5833 topic_id: 3534 reply_id: 10868[/import]
Version 0.5 is up, just added some helper functions for getting at Properties, Layers and Objects. Still trying to sort the layering stuff. [import]uid: 5833 topic_id: 3534 reply_id: 10875[/import]
personally I would not have the class return the displayObject directly, so that you could then instantiate the map without needing to instantate the display if required.
The plan is that version 1.0 will support the full feature set of Tiled (well maybe not full as I’m not sure about gzip compression stuff or Isometric maps).
Yea I think that could be a good idea about the separation, I will give it a think.
Edit - I’ve now updated it so that a Map object has a map.world property which is the actual displayGroup however haven’t uploaded the changes yet, will wait till I have more changes.
I have also just checked out of curiosity to see if it works on my Android phone (HTC Hero) and it does, which is nice. [import]uid: 5833 topic_id: 3534 reply_id: 10879[/import]
for i=1, #self.layers, 1 do
local layer = self.layers[i]
layer.g = display.newGroup()
self:insert(layer.g)
for j=1, #layer.tiles, 1 do
local sprite = layer.tiles[j]:createSprite(j)
if(sprite) then
–self:insert(sprite)
layer.g:insert(sprite)
[/lua]
in main.lua
[lua]people = map:getLayer(“People”).g
local onUpdate = function(event)
people.x=people.x+1[/lua]
you’ll see the people walk behind the house. of course it’ll break your scroller because the people make the display group wider
eventually it’ll probably need a setXY() function or something to make sure anything moved in the world is kept within bounds. although actually i’m not sure how gameplay will be separated out from the map system. maybe it shoulnd’t be part of the tilemap engine at all… but rather
Yea true, input would be good Need some more people to see this post and reply (or perhaps I should just make a post specifically for Lime) [import]uid: 5833 topic_id: 3534 reply_id: 10890[/import]
Version 0.6? It works here, I unzipped the upload and ran it. Perhaps the download got corrupted somehow. [import]uid: 5833 topic_id: 3534 reply_id: 10891[/import]
Ah right yea, that was the broken version anyway. Ignore that version just stick to the current 0.6 on my site [import]uid: 5833 topic_id: 3534 reply_id: 10896[/import]