Problem with Animations

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
DiegoG
Prole
Posts: 20
Joined: Sat Apr 29, 2017 2:43 am
Location: Venezuela

Problem with Animations

Post by DiegoG »

Hello, I've been working on a project for a while and just recently, while I was testing, I found a rather peculiar error in the animations handler I made -- It doesn't draw the image at all
I've checked all the relevant data I could think of, presence of assets, animation states, switching, quad switching (even checking their viewports) and everything flows just as it should, even the position. But for some reason the frames won't show up
I've compiled all the relevant files and made a small game with most of the same files, specially the same animation function, I've tested and it not only runs well but replicates the error seamlessly. I'd be very thankful if you could help me out with this! I've already gone ahead and set the love.graphics.print functions required to check the data I was viewing. Thanks in advance!
anim problem.love
(51.03 KiB) Downloaded 116 times
function earth:destroy()
00count=5000
00while count>0 do
0000lg.draw(explosion,math.random(0,600),math.random(0,800))
0000count=count-1
00end
00earth = nil
00print("Earth has been destroyed.")
end
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Problem with Animations

Post by zorg »

In your assets.lua, you do this:

Code: Select all

lg.newQuad(x,y,w,h,0,0)
It will never draw anything like that, since you're basically saying that with an image of size 0x0 as reference, you define quads in that; you need to pass in the width and height of the image you want to apply the quad on as the reference width and height.

Code: Select all

-- also move your animObj.img definition above this part
table.insert(states[i],lg.newQuad(x,y,w,h,animObj.img:getDimensions))
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
DiegoG
Prole
Posts: 20
Joined: Sat Apr 29, 2017 2:43 am
Location: Venezuela

Re: Problem with Animations

Post by DiegoG »

Wow.
I'm a moron.

Thanks for your help though! Really appreciated :D
It works now!
function earth:destroy()
00count=5000
00while count>0 do
0000lg.draw(explosion,math.random(0,600),math.random(0,800))
0000count=count-1
00end
00earth = nil
00print("Earth has been destroyed.")
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot] and 248 guests