google-code-export / gtge

Automatically exported from code.google.com/p/gtge
2 stars 0 forks source link

Add "restoreSprite" method to VolatileSprite #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The VolatileSprite class is normally used once and only once.  Normally, 
users will use a SpriteGroup to control sprites and remove inactive ones.  
However, if multiple VolatileSprites are needed (such as a shooting game), 
this may not be the best approach (VolatileSprites may need to have a 
different pooling mechanism, etc).

I propose adding the following method to the VolatileSprite class:

/**
  * Restores a <tt>VolatileSprite</tt> instance so that it will be rendered
  * again.
  */
public void restoreSprite() {
    this.setFrame(getStartAnimationFrame());
    this.setAnimate(true);
    this.setActive(true);
}

This will prevent users from simply making their own ad-hoc restore method 
in a subclass that might just exist for this purpose.

Original issue reported on code.google.com by CarlHol...@gmail.com on 6 Apr 2008 at 5:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Changed to Enhancement and Priority low.  Sorry about that, I was using a 
shared 
computer at the time and didn't realize someone else had signed into Google.

Original comment by MetroidF...@gmail.com on 6 Apr 2008 at 6:44

GoogleCodeExporter commented 9 years ago
Sprite can be set to immutable so it won't be disposed by SpriteGroup.
Adding restoreSprite won't be hurt to make it alive again :)

Original comment by pau...@yahoo.com on 6 Apr 2008 at 7:14

GoogleCodeExporter commented 9 years ago
I realized later that due to how setFrame works, setFrame(0) must be used for 
this 
method.

Original comment by MetroidF...@gmail.com on 7 Apr 2008 at 2:22