Log In  

Cart #nawiseseyo-1 | 2023-09-27 | Code ▽ | Embed ▽ | No License


Why is my code not drawing the tiles I want where they should?

Am i not understanding smth with classes?

P#134965 2023-09-27 14:31 ( Edited 2023-09-27 14:34)

It's because you're reusing the same tile object and updating its properties every time through the nested loop set, so by the time you're done, you have 256 identical tiles in the table at 15,15 with the same sprite. What you probably need to do is create some kind of object instantiation function to create a new object of class tile and instantiate a new tile before setting x,y & sprite. Object-oriented Lua is not my strong suit, but the Lua manual might be of help for getting the general idea.

P#134982 2023-09-27 16:09

this will help to create separate tables!
https://www.lexaloffle.com/bbs/?tid=44686

P#135016 2023-09-28 01:59

[Please log in to post a comment]