SO I'm making this game and my trying to add an animated powerup/health pack which heals the player. I tried reusing some code which I used to make an explosion animation but the way I've don't is obviously wrong and I need some help.

My Git hub below:
<https://github.com/Sirbraindamage/Games-and-Project.git>

This is the code explosion animation code I tried to adapt into the animated powerup

[![enter image description here](https://i.stack.imgur.com/EFQz6.png)](https://i.stack.imgur.com/EFQz6.png)

What it does it loops through all of the images when its called in main. it also scales the images to two sizes. the larger size it for when all bullets hit an NPC and the smaller one for when the NPC hits the player.

[![enter image description here](https://i.stack.imgur.com/nWN1I.png)](https://i.stack.imgur.com/nWN1I.png)

This code is similar to the one above as it loop through the images but tried incorporating it into a sprite to make a powerup but it didn't work.

[![enter image description here](https://i.stack.imgur.com/F2oF3.png)](https://i.stack.imgur.com/F2oF3.png)

This I how I tried to incorporate it into the sprite which didn't work...

[![enter image description here](https://i.stack.imgur.com/xghW5.png)](https://i.stack.imgur.com/xghW5.png)

This is an image of the error which appear when the powerup tries to spawn

[![enter image description here](https://i.stack.imgur.com/SXmok.png)](https://i.stack.imgur.com/SXmok.png)

This is the code that's used to spawn the powerup...

The rest of the codes in the Github (tell if it works or not I'm very new to GitHub)

So if anyone can find out how to add an animated powerup which heals the player I would be much appreciated. Also, There's a health variable under the player class if you're looking for it.

Also full code on Github

weird visual bug:
[![enter image description here](https://i.stack.imgur.com/q31im.png)](https://i.stack.imgur.com/q31im.png)