Animated Sprite In Window (Fixed)

Hello JS Coders,


I've been trying to make a sprite animate in a window for the longest time and have not been able to get it working. I assume I am doing something wrong with the creation of the sprite itself.


this.updateBitmap() is the function that shows the sprite on the window. (It sets this.bitmap to this.frame). I assume somewhere in here is where it goes wrong.


The sprite itself won't even show up! Also note that if I use var pic = bitmap, the image shows in its entirety as well as cut into the blt. 


This is what pic prints when using var pic = bitmap


GOgjnfK.png



This is what prints when var pic = new Bitmap(w, h)


Y8JLF3f.png



So now I'm wondering if my blt is wrong somehow because it shows one way and the other way it doesn't. I'm confused as to if I'm supposed to wait for pic to load because it's using an already loaded bitmap.


I then have my update method set to run this code:
 


Sprite_MenuAnimations.prototype.updateBitmap = function() {
this.bitmap = this.frames[this.frame];
};


This seems to work out (When I use the var pic = bitmap), but the previous image (from the animation) doesn't go away.


When using pic = bitmap, this seems to load the blt as well as the spritesheet itself. (If you look close enough, you can see the blt'd frames on row 3 col 3)


0OXtdkP.png



Which is an undesired effect. I just want the blt to show. 


Any help on this would be appreciated. I hope I have provided enough details to receive help on this!


Fixed! Thanks to Tsukihime for realizing my error.
I will close this, but please don't edit your post when it's fixed and set everything to strikethrough.  We keep posts around after they're resolved so others who have the same (or similar) questions can benefit from your thread, and strikethrough makes it a bit hard to read (and for the same reason, if you had an error, it's a good idea to say what it was, just so others can see the solution).

Original thread: https://forums.rpgmakerweb.com/threads/animated-sprite-in-window-fixed.58908/