-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object visibility is not respected #181
Comments
The issue with that is how sprite batches work. STI batches all the tiles in a layer into single draw calls, so toggling the visibility of individual objects would require manually modifying the batch upon toggle. I could probably add a function to each object that you could use to toggle the object's visibility which would adjust the sprite batch. |
My (admittedly uninformed) fix is:
I'm not too well informed about sprite batches so this "fix" probably doesn't fully work for the problem but it has worked in my simple case. https://github.com/karai17/Simple-Tiled-Implementation/blob/master/sti/init.lua#L820 |
That would work for Tiled's geometry objects, but not so well for tile objects that draw sprites, those get batched into a single draw call. |
Okay, so I ran into this same problem and my solution was to add a function that would recreate the batch for the layer and then in the Map:setObjectSpriteBatches function, I just added a condition of the object being visible.
So whenever I changed the visibility of an object, I called the updateLayerBatches and it worked great. I don't know if this is at all efficient or anything so let me know if this is totally stupid. |
The issue with the above code is that you're creating a whole new batch and rebuilding all of the objects instead of just updating the current batch and the one object. You're also not clearing any of the old data so your |
Creating an object layer in tiled, then adding an object with "Visible: False" property should make the object invisible when loaded in. Currently this variable seems to be ignored.
The text was updated successfully, but these errors were encountered: