Hey everyone, I am having some trouble with making my character “punch” once and then stop.
Right now what I am doing is, if the punch button is pressed it sets “punching” to true, then in the game loop, if punching is true, and the Fist rectangle intersects the enemy, then take 1 away from the enemies health, but the problem is if the person holds down punch the fist is just always out, like walking around with your hand sticking out, and it takes 1 away the entire time the rectangles are intersecting.
I figured out a way to fix this and that was by setting the Punching variable to false once the intersection occurred and then taking away 1 from the health and this worked fine however a problem with the animation occurs because in the player class, if punching is true it draws the punching frame. So if we make punching false right after the rectangles intersect it happens so fast that it never gets a chance to show the character punching.
So I guess the problem lies in my animation, I am wondering how I would make it so that on a button press it plays the Punch animation ( show punch frame, then back to standing)…That way I can also have it so when i press Z it will do a punch and then stop so the player wont be able to run around holding the punch and destroying everything.
Hope this makes sense, if it doesnt please ask and I will try to clear it up.
Is it running on LWJGL, JOGL ?