Page 12 of 92
Re: Simple Tiled Implementation - STI v0.6.14
Posted: Tue Mar 11, 2014 4:55 pm
by Clean3d
Unfortunately, if you want a good solution I can't help you. I have seperate .png images for each frame in the animation. All I'm doing is swapping out the image in the tileset and regenerating sprite batches.

My animations are only about 1fps, so I just hold my nose and put up with the clunkiness of this method.
Isn't there a Tiled branch with animated tiles? I'm hoping they'll still put that in 0.9.2 and then I can use it instead of my hack. It works for now, though.
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Tue Mar 11, 2014 5:05 pm
by Karai17
Yeah, Tiled 0.9.2 will have animations. You can actually download a nightly with animation support. Regenerating sprite batches seems like the only real way to go about it.
Edit: The spacing bug has now been fixed!
Edit: Also made ellipses less stupid~
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Mon Mar 17, 2014 12:10 am
by Cerulean Knight
Congrats for this library, STI is very good, simple, and has a great potential!
I'm using this, and was very easy to do everything work.
I want to do a suggestion, it would be great that we can access to the properties of the objects in the map, not only to draw a polygon, but for set startpoints or events, taking the (for example) the coordinates of an object (or even a propertie that we can set in the object itself).
Maybe you can suggest me a better way to do this, I'm starting so, I have a lot to learn.
Excuse me if something is confusing, I'm no native english speaker

Re: Simple Tiled Implementation - STI v0.6.16
Posted: Mon Mar 17, 2014 1:13 am
by Karai17
Thanks for choosing STI! To access Tile properties, you can do the following:
Code: Select all
local STI = require "sti"
local map = sti.new("map")
local prop = map.tiles[1234].properties -- select the properties from Tile 1234
Using Map.tiles[TILE].properties, you can access all of the properties from any tile in any tileset.
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Thu Mar 20, 2014 10:31 pm
by ochetski
Great lib, Karai17!
I've been testing it for a while now with "Tiled" generated maps, and it seems great.
Very few problems, but maybe it's just my low knowledge of your lib.
I have a few questions and hope it can help more people:
- Is there a way to get tile size from collision map? Did not found anything on your documentation.
- Have anyone used STI with a collision lib like love.physics or HardonCollider?
Links, cuz everyone löves them:
https://www.love2d.org/wiki/Tutorial:Ph ... nCallbacks
https://love2d.org/wiki/HardonCollider
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Thu Mar 20, 2014 11:20 pm
by Karai17
1) The built-in collision map has no actual size, it is just a binary map so it inherits the same size as the map tiles
2) I am unaware of anyone using STI coupled with external collision libs, but I would love to know of any results!
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Fri Mar 21, 2014 2:39 am
by ochetski
I asked because I did implemented a collision system with STI. But needed to set the tile sizes hard coded, because I wasn't able to get tiles width and height from the map.
My collision system is now ugly, complex and hard to use with multiple entities. I will probably change it to use love.physics. I will share it here as soon as I finish it.
Thanks Karai, please keep the good work because it will bring great games to life.
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Fri Mar 21, 2014 2:47 am
by Karai17
You should be able to access map.tilewidth and map.tileheight without any problem.
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Fri Mar 21, 2014 2:54 am
by Cerulean Knight
ochetski wrote:I asked because I did implemented a collision system with STI. But needed to set the tile sizes hard coded, because I wasn't able to get tiles width and height from the map.
My collision system is now ugly, complex and hard to use with multiple entities. I will probably change it to use love.physics. I will share it here as soon as I finish it.
Thanks Karai, please keep the good work because it will bring great games to life.
If you are using HardonCollider, you can add a few lines in the Map:getCollisionMap function.
So, the final result is this:
Code: Select all
function Map:getCollisionMap(index)
local layer = assert(self.layers[index], "Layer not found: " .. index)
assert(layer.type == "tilelayer", "Invalid layer type: " .. layer.type .. ". Layer must be of type: tilelayer")
local w = self.width
local h = self.height
local map = {
type = layer.type,
orientation = layer.orientation,
collision = true,
opacity = 0.5,
data = {},
}
for y=1, h do
map.data[y] = {}
for x=1, w do
if layer.data[y][x] == nil then
map.data[y][x] = 0
else
map.data[y][x] = 1
ctile = collider:addRectangle((x-1)*self.tilewidth, (y-1)*self.tileheight, self.tilewidth, self.tileheight)
collider:setPassive(ctile)
end
end
end
return map
end
Then, when you load a collision map, HC will create all invisible square on the map positions.
Note: collider is the variable that you define before
Code: Select all
collider = HC(100, on_collision,stop_collision)
Edit: changed size of tiles for variables.
Re: Simple Tiled Implementation - STI v0.6.16
Posted: Fri Mar 21, 2014 3:04 am
by Karai17
It might be worth adding in HC hooks for those who want to use it with STI. Feel free to file a feature request on GitHub and I'll look into it.