Animated Tile objects don't retain scale during animation.
When using Tiled's Animation system the scale of any object is lost upon the tile switching to it's next animation frame. I believe this bit of code is the issue.
j.batch:set(j.id, t.quad, j.x, j.y, j.r, tile.sx, tile.sy, 0, j.oy) https://github.com/karai17/Simple-Tiled-Implementation/blob/2a08bf4742d788dd8f35231c80657759e4adaf0d/sti/init.lua#L802
Since for a tile image based object the tile.sx is going to be the normal 1 or -1 without the additional scaling factor that was calculated when indexing over it in setObjectSpriteBatches(layer) https://github.com/karai17/Simple-Tiled-Implementation/blob/2a08bf4742d788dd8f35231c80657759e4adaf0d/sti/init.lua#L630
The issue seems to be that the instance's information is being overwritten when the tile is updated and it's not taking into account the sx that was calculated based upon the size of the tile itself.
I'm thinking about trying to take on this fix. Are the objects in the tile instances actual references to the batched object? As in do I still have access to the properties of the original object when accessing it as a tileInstance?
If so then I think the fix should be relatively simple(and I can write it myself) but I wanted to be sure before I go down a rabbit hole that'll lead me to no where.
The instances should have access to the root object, yeah.
Landon Manning [email protected]
On Sat, 3 Oct 2020 at 20:06, Macathur Inbody [email protected] wrote:
I'm thinking about trying to take on this fix. Are the objects in the tile instances actual references to the batched object? As in do I still have access to the properties of the original object when accessing it as a tileInstance?
If so then I think the fix should be relatively simple(and I can write it myself) but I wanted to be sure before I go down a rabbit hole that'll lead me to no where.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/karai17/Simple-Tiled-Implementation/issues/241#issuecomment-703175316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQD7FBZ6XVCJXZXXQGC6LSI6U5XANCNFSM4Q5ASFNQ .
OK thanks, I'll fix this bug with the update function when objects are set to utilize a tile that has an animation. After I confirm it's working I'll create a PR and reference this issue. I'll try to keep the amount of changed lines to a minimum. As I think that's the only major thing left before I can create my game. I just cloned the latest master and will start work on a new branch as I try to see if my fix'll work.
P.S. Thanks again for all of the work you've already put into this library as I know there's 0% chance that I'd ever be able to finish my own project without yours.
PRs are always welcome :)
Also, a tip: you can set the algorithm used for image scaling in the image object! for clean pixel art upscales you want to use "nearest", something like this:
local texture = love.graphics.newImage("path/to/image.png") texture:setFilter("nearest", "nearest")
Landon Manning [email protected]
On Sat, 3 Oct 2020 at 20:29, Macathur Inbody [email protected] wrote:
OK thanks, I'll fix this bug with the update function when objects are set to utilize a tile that has an animation. After I confirm it's working I'll create a PR and reference this issue. I'll try to keep the amount of changed lines to a minimum. As I think that's the only major thing left before I can create my game.
Basically I am going to have the "boss" mobs just be scaled up versions of the sprites that just stand there on the left-hand side like a standard RPG. If I come across other minor issues I'll try to keep fixing them in the codebase so that others can have an easier go than I had.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/karai17/Simple-Tiled-Implementation/issues/241#issuecomment-703177011, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQD7ELYJFINNFJMOKVB7TSI6XV3ANCNFSM4Q5ASFNQ .
It's scaled in the tiled map currently and it's always an integer scale. Plus I have the whole world scaled with nearest filter. I made sure to make everything an integer scale.
I have the thing working but it's going to add ~16b(assuming that LuaJit uses Doubles for it's floating point numbers) of memory per object that uses a tile image. I know there has to be some way to access the properties of a batched instance as you have the ID to set it, but I've yet to dig into the Love2D codebase to figure out how as that seems like a waste of good memory to add 2 more properties to the tile instance table.
If I can't find a way to fix it w/o adding the 2 properties then I'll leave it be as it's not a ton of memory but still it feels inefficient having to lug around all that extra metadata for each tile instance. If I can't find a way to fix it the other way by tomorrow then I'll leave it be and submit the PR as is(it's still just on my local repo in a branch)
Lua and LuaJIT both use doubles for all numbers, though Lua 5.3 now has integers. I'm not too worried about a few bytes of data.
Landon Manning [email protected]
On Sun, 4 Oct 2020 at 02:26, Macathur Inbody [email protected] wrote:
It's scaled in the tiled map currently and it's always an integer scale. Plus I have the whole world scaled with nearest filter. I made sure to make everything an integer scale.
I have the thing working but it's going to add ~16b(assuming that LuaJit uses Doubles for it's floating point numbers) of memory per object that uses a tile image. I know there has to be some way to access the properties of a batched instance as you have the ID to set it, but I've yet to dig into the Love2D codebase to figure out how as that seems like a waste of good memory to add 2 more properties to the tile instance table.
If I can't find a way to fix it w/o adding the 2 properties then I'll leave it be as it's not a ton of memory but still it feels inefficient having to lug around all that extra metadata for each tile instance. If I can't find a way to fix it the other way by tomorrow then I'll leave it be and submit the PR as is(it's still just on my local repo in a branch)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/karai17/Simple-Tiled-Implementation/issues/241#issuecomment-703205096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQD7GSSWMYVJ6UQKNSCCTSJABQ7ANCNFSM4Q5ASFNQ .
OK I created the pull request after pushing my code upstream. The fix(if you want to call my paltry change) a true fix does work. I verified it manually by having 3 objects all using the same tile image as their base and then setting their scale to be different amounts. All were integer one was 1x, one 2x, and one 3x. Then I watched the animations play out to verify that they all stayed their correct sizes.
I'll try to continue to dig through the code-base for any other items. Also the line about the offset for the y position was removed because for some reason upon sprite-update the sprites would all move up 1 tile's height which makes me think that somehow they were rendered in the correct position all along. That was also manually verified by watching for sprite movements from the same visual representation in Tiled(not pixel offsets obviously).