Page 47 of 92

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Sun Apr 10, 2016 1:02 pm
by zugende
Karai17 wrote:Looks like you mostly have it. I think the batch id should be in the tile instance, so that will tell you exactly which part of the batch you need to update.
Still not working, but I dont give up. :D

ok, this is what I got so far:

1) mouse click
2) tile-x and tile-y is calculated -> then I look up the GID

Code: Select all

mouse.clickedTile = map.layers[1].data[tiley][tilex].gid
3) then I loop through all the instances within the GID to check which x+y coordinate(calculated like tile-x/tile-y var) matches the tile-x and tile.y coordinate

Code: Select all

for i, instance in ipairs(map.tileInstances[mouse.clickedTile]) do
   if instance.x/24+1 == tilex and instance.y/24+1 == tiley then
      print("GID:",instance.gid,"ID:",instance.id,"i:",i)
      mouse.instanceNr = i
   end
end
      
Works perfectly!

4) Now my plan is to change the quad with this function:
batch_setq.JPG
batch_setq.JPG (27.47 KiB) Viewed 4296 times
.. but it dont works.. why? :cry:

Code: Select all

attempt to call method 'setq' (a nil value)
Hope you can help me again.
Thanks so much!
zugende

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Sun Apr 10, 2016 1:41 pm
by s-ol
setq doesn't work because it doesn't exist, which is what the error is telling you: setq is a nil value (= nothing). Look at the wiki screenshot you posted, on the right it says that :setq was removed in version 0.9.0. if you look at the wiki page of :setq it also tells you that "It has been merged into SpriteBatch:set".

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Tue Apr 12, 2016 8:38 pm
by zugende
Just want to say thanks to Karai17 and s-ol for their help! :)
The

Code: Select all

SpriteBatch:set
function was the solution.
spritebatch_edit.gif
spritebatch_edit.gif (453.06 KiB) Viewed 4237 times
Best
zugende

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Tue Apr 12, 2016 8:40 pm
by Karai17
Cool!

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Sun Apr 17, 2016 11:48 am
by Temeez
Hey, any chance you could update your tutorial at http://lua.space/gamedev/using-tiled-maps-in-love as it doesn't seem to work with the newest Löve version (0.10.1)? The layer.update and layer.draw functions in the love.load() seem to do nothing, so the end result of that tutorial is a invisible player which doesn't move.

Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
and then in the love.draw(), after map:draw() I put layer:draw()
The layer of course needs to be global. Similar thing with the layer.update.

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Sun Apr 17, 2016 1:26 pm
by zorg
Temeez wrote:Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
Those two should be equivalent code, since it's nothing Löve specific, rather lua specific, and the used lua version didn't change, so, weird that that would solve any issues :v

Re: Simple Tiled Implementation - STI v0.14.1.12

Posted: Sun Apr 17, 2016 1:28 pm
by Temeez
zorg wrote:
Temeez wrote:Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
Those two should be equivalent code, since it's nothing Löve specific, rather lua specific, and the used lua version didn't change, so, weird that that would solve any issues :v
Looks like even the first one works, if I just put

Code: Select all

layer.draw(layer)
in the love.draw() function.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Thu May 19, 2016 4:15 pm
by Karai17
I've upgraded STI to a new version. Not a huge upgrade, just added some tests and fixes mostly. I plan to spend time soonish updating to Tiled 0.16.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Mon May 30, 2016 10:31 pm
by amcoolio
I have that glitch where when the player moves, it looks like my individual map tiles are breaking at the seems similar to the OP in viewtopic.php?t=82141 . However I can't figure it out like they did. Does it have to do with the player movement code? Sorry, new to programming

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Mon May 30, 2016 10:34 pm
by Karai17
You need to use math.floor to make sure you are translating and drawing to an internet value.