Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.9.7
You can set the map's collision data, or you can define a player's min/max x/y positions
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.9.7
Hi there. Is there a way to get a tile id? I just found out how to get a tile properties but not its id. Thanks!
Edit: Just found out how. I created a small function to do it. Now I can access all the tile data too. Here's the code:
e.g.:
Edit: Just found out how. I created a small function to do it. Now I can access all the tile data too. Here's the code:
Code: Select all
function Map:getTileData(layer, x, y)
local tile = self.layers[layer].data[y][x]
if not tile then return {} end
return tile
end
Code: Select all
print(map:getTileData(layer,x,y).gid)
Re: Simple Tiled Implementation - STI v0.9.7
Hi,
I'm having troubles (because I'm just a beginner). Could you give me the basic code to have a map I could translate, and scale (zoom-in, zoom-out) nicely ? Because what I've been doing is rather ugly, and not very much close to what I want.
Or perhaps it is easier to do this with a lib designated for camera management ?
Thank you !
I'm having troubles (because I'm just a beginner). Could you give me the basic code to have a map I could translate, and scale (zoom-in, zoom-out) nicely ? Because what I've been doing is rather ugly, and not very much close to what I want.
Or perhaps it is easier to do this with a lib designated for camera management ?
Thank you !
Code: Select all
function love.load ()
sti = require "Simple-Tiled-Implementation"
-- map is 1536x2560 px, 12x20 tiles, each tile is 128x128 px
map = sti.new("map")
zoom = 1
translateX, translateY = 0, 0
end
function love.update(dt)
if love.keyboard.isDown('up') then translateY = translateY + 20
elseif love.keyboard.isDown('down') then translateY = translateY - 20 end
if love.keyboard.isDown('left') then translateX = translateX + 20
elseif love.keyboard.isDown('right') then translateX = translateX - 20 end
if translateX > 0 then translateX = 0 end
if translateX < -1536 + love.graphics.getWidth() then translateX = -1536 + love.graphics.getWidth() end
if translateY > 0 then translateY = 0 end
if translateY < -2560 + love.graphics.getHeight() then translateY = -2560 + love.graphics.getHeight() end
map:update(dt)
end
function love.draw()
love.graphics.push()
love.graphics.translate(translateX, translateY)
map:setDrawRange(translateX, translateY, love.graphics.getWidth(), love.graphics.getHeight())
map:draw(zoom, zoom)
love.graphics.pop()
love.graphics.print(tostring(love.timer.getFPS(), 10, 10))
love.graphics.print(tostring(translateX), 10, 20)
love.graphics.print(tostring(translateY), 10, 30)
love.graphics.print(tostring(zoom), 10, 50)
end
function love.mousepressed (x, y, b)
if b == 'wu' then
zoom = zoom + 0.1
elseif b == 'wd' then
zoom = zoom - 0.1
end
end
function love.resize(w, h)
map:resize(w, h)
end
Re: Simple Tiled Implementation - STI v0.9.7
What is it you are trying to do, and what is actually happening? Could you provide a love file for me to examine?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.9.7
Hey Karai
Thanks for STI, really appreciate it. However I'm having a problem I can't seem to fix. I attached my love file(sorry for the mess) so you can check it but I think the problem lies in the way I made the map in tiled. I tested it with your tech demo map and it worked fine so I believe I'm missing some settings or whatever.
I made a basic tileset and added 7 layers to the map. The only difference I see between your and my map is that I have Terrains set up. Otherwise I added the "collidable" "true" properties by hand to the specific tiles. Is there anything else to do? I exported the map in lua and loaded it up, then I get this:
What could be the issue? Thanks in advance!
Thanks for STI, really appreciate it. However I'm having a problem I can't seem to fix. I attached my love file(sorry for the mess) so you can check it but I think the problem lies in the way I made the map in tiled. I tested it with your tech demo map and it worked fine so I believe I'm missing some settings or whatever.
I made a basic tileset and added 7 layers to the map. The only difference I see between your and my map is that I have Terrains set up. Otherwise I added the "collidable" "true" properties by hand to the specific tiles. Is there anything else to do? I exported the map in lua and loaded it up, then I get this:
Code: Select all
modules/STI/map.lua:278: attempt to index field 'properties' (a nil value)
Traceback
modules/STI/map.lua:278: in function 'initWorldCollision'
main.lua:35: in function 'load'
[C]: in function 'xpcall'
- Attachments
-
- map.love
- (44.45 KiB) Downloaded 126 times
Re: Simple Tiled Implementation - STI v0.9.7
Your file does not load for me, you didn't copy all of the files. That being said, I notice that you're using an older version of Tiled. Try using 0.11.Raskol wrote:Hey Karai
Thanks for STI, really appreciate it. However I'm having a problem I can't seem to fix. I attached my love file(sorry for the mess) so you can check it but I think the problem lies in the way I made the map in tiled. I tested it with your tech demo map and it worked fine so I believe I'm missing some settings or whatever.
I made a basic tileset and added 7 layers to the map. The only difference I see between your and my map is that I have Terrains set up. Otherwise I added the "collidable" "true" properties by hand to the specific tiles. Is there anything else to do? I exported the map in lua and loaded it up, then I get this:
What could be the issue? Thanks in advance!Code: Select all
modules/STI/map.lua:278: attempt to index field 'properties' (a nil value) Traceback modules/STI/map.lua:278: in function 'initWorldCollision' main.lua:35: in function 'load' [C]: in function 'xpcall'
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.9.7
Hm, am I? I thought I got the 0.11 version. I think you probably saw the other map file? I included the one from your tech demo for testing, I guess that was created with an older version.
Tried another love file. Now it loads your map by default, you can check the mentioned error message if you modify line 29 in the main file
map-2 is your tech demo map wich works, map-1 is mine(which don't). Both of them are in the assets/maps folder. Thanks a mil!
Tried another love file. Now it loads your map by default, you can check the mentioned error message if you modify line 29 in the main file
Code: Select all
map = sti.new("assets/maps/map-2")
- Attachments
-
- map2.love
- (249.83 KiB) Downloaded 138 times
Re: Simple Tiled Implementation - STI v0.9.7
Ah, I see the issue. I just pushed a fix.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.9.8
Awesome, it works! Thanks mate
Re: Simple Tiled Implementation - STI v0.9.8
Hi,
First of all, thanks a lot for STI!
But I'm just wondering if there is any support for tiles that contain transparency, sorry if i've missed it. When I draw tiles that are transparent (even though they have tiles on lower layers), the transparent sections appear white.
First of all, thanks a lot for STI!
But I'm just wondering if there is any support for tiles that contain transparency, sorry if i've missed it. When I draw tiles that are transparent (even though they have tiles on lower layers), the transparent sections appear white.
Who is online
Users browsing this forum: No registered users and 7 guests