Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.9.2
That I do, thanksClean3d wrote:Jeeper, you will also need to call map:update(dt) in your update loop.
Thats quite amazing! ThanksKarai17 wrote:Tiled supports animated tiles natively, so do it in Tiled and it'll work in STI.
Re: Simple Tiled Implementation - STI v0.4.0
How can I "catch" the object initialization? I use Tiled objects as "entities" for a custom collision map and spawn points, so how do I grab these and not have them rendered as polygons?Karai17 wrote:¡Double Post!
STI v0.4.0 now draws Object Layers, so all the main things are in place! The library still needs optimization, among other things, but I would suggest that it could actually be used now if you're not too worried about performance, or have smaller sized maps. Performance optimizations will come in time, and should be a drop-in replacement so feel free to get used to the library's API now.
If you find any bugs, want to request a feature, feel free to add an issue in the GitHub Issue Tracker, or post here if you do not have a GitHub account.
I updated the love file in the OP, and I will be writing documentation in the near future. For now, you can check out the Quick Example on GitHub to get started.
EDIT: nvm, I figured it out. I ended up just iterating over map.layers[LAYERNAME].objects and calling map:removeLayer( LAYERNAME ).
Re: Simple Tiled Implementation - STI v0.9.2
Aye, that's about the right way to do it. Glad you found the answer!
Alternatively, you can just set layer.visible to false if you want to hold onto the data.
Alternatively, you can just set layer.visible to false if you want to hold onto the data.
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.2
I backed it up in a table called "olayer" so it doesn't even produce the tiniest overhad because I didn't know how "smart" layer.visible was being handled.Karai17 wrote:Aye, that's about the right way to do it. Glad you found the answer!
Alternatively, you can just set layer.visible to false if you want to hold onto the data.
Well, not going to fix that, I'm in a jam and winners don't refractor
Re: Simple Tiled Implementation - STI v0.9.2
Ohai! I think I found a problem. If I instance multiple maps the previous disappear... It's fairly easy to replicate, all you have to do is load two maps and try to draw them both.
Re: Simple Tiled Implementation - STI v0.9.2
Are you loading them into the same variable?
Also draw order and position is important. If you draw one map over top of the other, the first one is going to be hidden behind the second. You need to either draw one at a time, draw one offset to be beside the other, or draw one with some transparency.
Also draw order and position is important. If you draw one map over top of the other, the first one is going to be hidden behind the second. You need to either draw one at a time, draw one offset to be beside the other, or draw one with some transparency.
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.2
No, I managed to fix the problem though. framework.clear is called but it doesn't clear the actual canvas, instead it was clearing the screen.
Re: Simple Tiled Implementation - STI v0.9.2
Eh? That's weird. Each instance should have its own canvas and framework.clear shodul clear that canvas.
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.2
@Karai17, I did tweet to you the other, yet somehow I'm still having serious problem access the tile id. Here's the full code of a test run of STI:
PS: I have noted a syntax error, should have been data[cy][cx], but I don't think that's the problem here.
So far I have able to use the formula at line 24 to accurately get the tile coordinates of the cursor, yet I am unable to utilize these variables to access the tile id.
Line 29 can randomly get me the desired result with smaller tile coordinates(?) before giving me error (attempt to index a nil value) while I move my cursor to the bottom right corner of the screen. To get this to work, keep your cursor to the top left corner of the screen while running the *.love file. Yes I know this is weird, but I have tried and can confirm it.
On the other hand, line 30 has been an outright error without any excuse or exception.
I have already spent way too much time struggling with this. Is there anything I'm doing wrong?
PPS: looks like it's giving error when cursor is on a nil tile of that layer. Make sense, but this is making things difficult. Shouldn't it return 0 instead of this error?
Code: Select all
local sti = require 'sti'
M = {}
function love.load()
love.graphics.setBackgroundColor(40,40,40)
map = sti.new("maps/tile_01")
end
function love.update(dt)
map:update(dt)
end
function love.draw()
map:draw()
love.graphics.setColor(255,255,255)
love.graphics.print(love.timer.getFPS(), 0, 00)
love.graphics.print(love.mouse.getX(), 0, 40)
love.graphics.print(love.mouse.getY(), 0, 60)
local cx, cy = math.ceil(love.mouse.getX() / map.tilewidth), math.ceil(love.mouse.getY() / map.tileheight)
love.graphics.print(tostring(cx), 0, 80)
love.graphics.print(tostring(cy), 0, 100)
love.graphics.print(tostring(map.layers['forelayer'].data[cx][cy].gid), 0, 200)
love.graphics.print(tostring(map.layers['collision'].data[cx][cy].gid), 0, 200)
end
function love.keyreleased(key)
if key == "escape" then
love.event.quit()
end
end
So far I have able to use the formula at line 24 to accurately get the tile coordinates of the cursor, yet I am unable to utilize these variables to access the tile id.
Line 29 can randomly get me the desired result with smaller tile coordinates(?) before giving me error (attempt to index a nil value) while I move my cursor to the bottom right corner of the screen. To get this to work, keep your cursor to the top left corner of the screen while running the *.love file. Yes I know this is weird, but I have tried and can confirm it.
On the other hand, line 30 has been an outright error without any excuse or exception.
I have already spent way too much time struggling with this. Is there anything I'm doing wrong?
PPS: looks like it's giving error when cursor is on a nil tile of that layer. Make sense, but this is making things difficult. Shouldn't it return 0 instead of this error?
- Attachments
-
- test-sti.love
- (19.52 KiB) Downloaded 139 times
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 1 guest