I'm also having artifacts sometimes when I'm hiding and showing sprites. The following image shows an example of when I'm hiding the sprite over the block that shows the block content (the gray block is the background and is overlayed by a sprite showing the question mark or the block content). This problem happens when the shield is over the block, and I'm hiding the block sprite. I will probably need to create a simpler code reproducing the artifacts problem to help you.
These are the steps I'm using for creating sprites:
1) I'm loading the PNGs into different pages when the game starts using:
const SCREEN_BUFFER=2 ' Screen buffer number const MAP_TILES_BUFFER=3 ' Map tileset buffer number const OBJ_TILES_BUFFER=4 ' Objects tileset buffer number const BOSSES_TILES_BUFFER=5 ' Bosses tileset buffer number const GENERAL_USE_BUFFER=6 ' General use buffer number
2) In the main loop, I'm drawing the map tiles in the SCREEN_BUFFER and also scrolling the background
3) I'm spawning new sprites when necessary in the SCREEN_BUFFER using: