Hi there,
a7s1h1 wrote:The problem is that sometimes <something happens but I don't know why>. I doublechecked all the pieces of my code to find that ugly trigger, but to no avail. Then I decided <to do something else which doesn't fix the issue, but masks it>
Every time you find yourself in that situation, stop. Usually masking the real issue is not a good solution. Keep chasing the problem, sleep on it, add lots of prints, or even rewrite the whole thing, until you understand clearly what the issue is. Don't bury it with more code that masks the issue. You would be just laying traps for your future self.
It's good to spend time getting the foundations right, before building on top of them; otherwise when the house is half-built, it'll collapse.
a7s1h1 wrote:So, the question is "Is there any way to check if the animation is currently on or not?"
Well, it depends on what you mean by "on". If you mean "playing", yes, you can check that by doing if anim.status == "playing" then [...] .
However I don't recommend it. The reason is that you would be using animations for something they are not designed for.
Animations should change according to what your code tells them, like this:
Code: Select all
if player:isDying() then
player.dyingAnimation:setFrame(1)
player.setAnimation(player.dyingAnimation)
end
You are trying to do it the other way around - the animation is controlling your code.
Code: Select all
if anim.status == "playing" then
<other game code>
end
Let me use an analogy. Imagine that you are doing a platformer, where the player is mostly green and the platforms are mostly red. If you coded it the way you are attempting to use animations, you would be drawing the player and the platforms on the screen, and then reading some pixel colors from the screen to detect if the player was on a platform (instead; you should use the player and platform coordinates and detect how they collide with maths).
I strongly recommend going back to your code and understanding what really happens there. If you need help, I recommend opening a post in the support forum and putting a *.love file there, so others can help you (please don't upload it directly on this thread, since it seems that anim8 is not your real problem here).
In any case, good luck solving your issues!