Dragonfly Q&A

Issues with unloading Sprite

0 like 0 dislike
I'm currently experiencing an issue with unloadSprite() method.

I'm not sure why, but calling it once will result in having the whole p_sprite array cleared. My call to delete the Sprite after finding it simply is "delete p_sprite[i];" and then the remainder of the p_sprite is parsed to move the other sprite positions.

Any ideas on why this behavior could be observed?
asked Sep 29, 2014 in Engine Development by lrlebrao
I found the issue, my second loop was iterating using a wrong variable and going through all 10000 sprites of p_sprite.
Good!  I posted the answer below before I saw your comment.

1 Answer

0 like 0 dislike

Your delete call looks right. 

Are you doing something unintended when you are scooting the array over after deletion?  Something like:

  // Scoot over remaining sprites.
  for j = i to sprite_count-2
    p_sprite[j] = p_sprite[j+1]
    decrement sprite_count
  end for


Where your "decrement sprite_count" is inside the loop?  If not, try printing out sprite_count at the beginning and end of the method and see if you can narrow down where it is getting changed.
 

 

answered Sep 30, 2014 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.
...