-
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
Animated Tile objects don't retain scale during animation. #241
Comments
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 ***@***.***> 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
<#241 (comment)>,
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. P.S. |
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 ***@***.***> 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
<#241 (comment)>,
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 ***@***.***> 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
<#241 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEQD7GSSWMYVJ6UQKNSCCTSJABQ7ANCNFSM4Q5ASFNQ>
.
|
…ove2d sprite batch but for now this will fix it. I am wasting another 16 bytes of data per object/tile overall. I think that I might be able to do something like batch[id].sx and batch[id].sy to get th metadata but that's up for a later release once I am done with this one as I am not going to fix something that is currently already working. Fixes issue karai17#241
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. |
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)
Simple-Tiled-Implementation/sti/init.lua
Line 802 in 2a08bf4
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)
Simple-Tiled-Implementation/sti/init.lua
Line 630 in 2a08bf4
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.
The text was updated successfully, but these errors were encountered: