I am currently facing a specific optimization problem but any general optimization tips about Lua and Love would be greatly appreciated.
My contribution is this nifty little link I came across: http://trac.caspring.org/wiki/LuaPerfor ... :for-loops
My problem right now is in my animation system. What I have is a system where, I give it a Sheet.png and a Sheet.json, which is the pieces of an object, dissembled like so:
And then an "Anim.json" file has the information of where each piece is supposed to go on each frame. The problem is that this animation update function is terribly laggy. I've confirmed that it is *not* from the amount of objects on screen, because simply commenting out the animation update removes the lag.
I can't really see anything too CPU heavy that I'm doing in my animation update step, so hopefully someone can offer some tips.
I've attached the file below. The loop, which if commented out the lag stops, starts on line 145. If you'd rather not download anything, here's a pastebin with the loop on its own (Although format is a bit messed up):
http://pastebin.com/mCGSJYmS
The difference between the game with this loop and without it is huge. With: ~9-15 fps. Without: ~110 fps.
I have a global animation array which I go through and call this update function:
Code: Select all
for i=1,#_AnimationArray,1 do
_AnimationArray[i]:Update(dt * _b2Factor)
end
I'm under the impression that Lua is a pretty fast language, although I haven't tried doing any tests myself, so I'm guessing I must have screwed up badly to make it lag this much.
Thanks in advance!
(Again, even if you just have general tips about optimizing with Love, that'd be great. Like whether rendering images with drawq is slower than rendering it normally, or any such things)