If you remove all the layers then ipairs can't find anything and it will throw an error.
In the orthogonal map, the sprite is embedded directly into the sprite layer so it is only updated when that layer is updated, same with draw.
STI updates and draws layers in order, so if you have a tile layer over top of your sprite layer, then your sprite will be drawn below those tiles. Make sure your order is correct and nothing is being hidden behind tiles.
Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.9.8
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
Ah right if all the layers are deleted then there wont be any layers for STI to iterate over, but the issue comes from only have one layer, specifically a tile layer, rather than multiple different layers. I have finally figured how how to successfully render the custom sprite added to the project, in the Orthogonal that would be kim.jpg.
I found that this sprite seems to only be drawn after a second layer is added to the map. Hence if a new map is created, with only a tile layer, no custom sprites will render, however if an object layer is added then the custom sprite renders.
Ah ha! I found the issue, well not directly.
So I was able to get the sprite to render with only have one layer, it seems the issue comes from when the map adds a custom layer and if the depth of the layer is set at a depth higher than the total number of layers (+1)? I'm not sure if the layers are indexed by one or not.
So in the example the map added a custom layer named "Sprite Layer" and passed in the parameter 3, so if there is one layer, then this one won't be rendered because there is a missing layer 2, by changing the 3 to a 2 the sprite now renders. Additionally by incremented the index from 3 to 4 or 5, the same issue stays. Lastly I find it a bit odd if say adding a custom layer and the index is the same as an already existing layer, as it does seem to render everything like it should, but this is a pretty strange discrepancy.
I found that this sprite seems to only be drawn after a second layer is added to the map. Hence if a new map is created, with only a tile layer, no custom sprites will render, however if an object layer is added then the custom sprite renders.
Ah ha! I found the issue, well not directly.
So I was able to get the sprite to render with only have one layer, it seems the issue comes from when the map adds a custom layer and if the depth of the layer is set at a depth higher than the total number of layers (+1)? I'm not sure if the layers are indexed by one or not.
So in the example the map added a custom layer named "Sprite Layer" and passed in the parameter 3, so if there is one layer, then this one won't be rendered because there is a missing layer 2, by changing the 3 to a 2 the sprite now renders. Additionally by incremented the index from 3 to 4 or 5, the same issue stays. Lastly I find it a bit odd if say adding a custom layer and the index is the same as an already existing layer, as it does seem to render everything like it should, but this is a pretty strange discrepancy.
Re: Simple Tiled Implementation - STI v0.9.8
If the layer already exists, it simply inserts it and pushes everything else up.
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é
-
- Prole
- Posts: 3
- Joined: Sun Jun 07, 2015 3:31 am
Re: Simple Tiled Implementation - STI v0.9.8
Hey, first I want to say that your library was how I discovered Love. I was looking for a game engine that could be used with tiled because I was sick of making maps by hand and through the supported games engines I saw love2d and the supporting library was yours.
I have made a simple test of your library just to wet my feet before I actually take the time to Organize and compartmentalize my code in preparation for something more long term and I keep on running into a very odd glitch where tiles are rendering fine when standing still, but when the camera moves the tile position update makes horizontal artifacts.
I suspect floating point errors but I figured you would know best. I could add a 2px buffer to all my tiles, But is not very elegant so I was hoping you know a better way.
This was very difficult to capture, I was only able to because rarely when the player stops moving it is perfectly on a seam-line frame
Update: It seems to only happen regularly at the peak of a jump when the vector is not vertical I guess when gravity makes the players position change too accurately with tiny decimals.
Maybe I should give the camera a little lag time?
Update2: I isolated the issue by chance. If Tilemap:setDrawRange(x, y, width, height) receives a decimal n + 0.5 for x or y the rounding function dies. solution was to have n + 0.5 vaules changed to n + 0.51 before calling the function
I have made a simple test of your library just to wet my feet before I actually take the time to Organize and compartmentalize my code in preparation for something more long term and I keep on running into a very odd glitch where tiles are rendering fine when standing still, but when the camera moves the tile position update makes horizontal artifacts.
I suspect floating point errors but I figured you would know best. I could add a 2px buffer to all my tiles, But is not very elegant so I was hoping you know a better way.
This was very difficult to capture, I was only able to because rarely when the player stops moving it is perfectly on a seam-line frame
Update: It seems to only happen regularly at the peak of a jump when the vector is not vertical I guess when gravity makes the players position change too accurately with tiny decimals.
Maybe I should give the camera a little lag time?
Update2: I isolated the issue by chance. If Tilemap:setDrawRange(x, y, width, height) receives a decimal n + 0.5 for x or y the rounding function dies. solution was to have n + 0.5 vaules changed to n + 0.51 before calling the function
- Attachments
-
- STI Test.love
- The code in Question
- (93.32 KiB) Downloaded 209 times
Re: Simple Tiled Implementation - STI v0.9.8
Hey, sorry the the excessively late reply!
So this issue is caused by scaling. You can try one of two things to fix this.
1) put your scaleX and scaleY value sinto map:draw
2) do the above and in sti/map.lua line 784, add love.graphics.scale(sx, sy) and remove the sx, sy from framework.draw()
Let me know your results!
So this issue is caused by scaling. You can try one of two things to fix this.
1) put your scaleX and scaleY value sinto map:draw
2) do the above and in sti/map.lua line 784, add love.graphics.scale(sx, sy) and remove the sx, sy from framework.draw()
Let me know your results!
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é
-
- Prole
- Posts: 3
- Joined: Sun Jun 07, 2015 3:31 am
Re: Simple Tiled Implementation - STI v0.9.8
Thanks a lot for the response! It came at the right time as I just "finished" a boilerplate for love and got my artist to start work on some *actual* art to replace my terribad placeholder stuff that I'd made (and acquired from open game art in the case of tiles).
Considering the high quality of your documentation it was completely my fault for not realizing that I would need to do my own rounding if I wanted my own scaling to work.
I have another question do objects have accessible x/y values in layers? I want to use A* for pathfinding which needs to know node data to be able to make a node graph. I could have a separate file or something but it would be nice to be able to edit stuff like that from tiled.
Could I modify your code that checks for collide=true to check for nodex and nodey as well? or do objects, for instance a rectangle have something like layer.indexofobject.x
Considering the high quality of your documentation it was completely my fault for not realizing that I would need to do my own rounding if I wanted my own scaling to work.
I have another question do objects have accessible x/y values in layers? I want to use A* for pathfinding which needs to know node data to be able to make a node graph. I could have a separate file or something but it would be nice to be able to edit stuff like that from tiled.
Could I modify your code that checks for collide=true to check for nodex and nodey as well? or do objects, for instance a rectangle have something like layer.indexofobject.x
Re: Simple Tiled Implementation - STI v0.9.8
For actual objects, they should each have an x and y location. For tiles, you're going to need to to either count them or run some pixel point on the screen through one of the convert functions to convert it from screen space to tile space (and then cut off the decimal).
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
Hello, it's me again. Running my game under ProFi I've noticed that STI spends too much time in drawObjectLayer method. I've found out that it draws (or at least tries to draw) rectangular shapes even for tile objects which normally have their width and height set to 0. This results in nothing being drawn yet greatly affects performance. Since tile objects are not meant to have non-zero width and height is it really necessary to do the extra work? I've seen you've mentioned that rectangles shouldn't be drawn in this case but it looks like some users may rely on this [undocumented] functionality.
Re: Simple Tiled Implementation - STI v0.9.8
Had a brief look through the thread, and I couldn't find any information on how to do this. Maybe I'm just blind, but I couldn't find this in the documentation either, and it just seems like something really basic and something that should be easy to do.
Anyway, how do I loop through all the tiles in the map/layer and get all their properties? For example, maybe something like:
How can one achieve this? I'm pretty sure you can do this (I believe it was possible in ATL), because as I said it's a pretty fundamental thing to be able to do
Thanks in advance!
Anyway, how do I loop through all the tiles in the map/layer and get all their properties? For example, maybe something like:
Code: Select all
for i,tile in ipairs(map.tiles) do -- or maybe ipairs(layer.tiles)?
print('Tile X: ' .. tostring(tile.x) .. '\nTile Y: ' .. tostring(tile.y))
end
Thanks in advance!
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Simple Tiled Implementation - STI v0.9.8
Code: Select all
local layer = map.layers["Tile Layer 1"]
for y=1, #layer.data do
for x=1, #layer.data[y] do
local tile = layer.data[y][x]
if tile then
-- do a thing
end
end
end
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é
Who is online
Users browsing this forum: No registered users and 6 guests