com.threerings.media.sprite
Class SpriteManager

java.lang.Object
  extended by com.threerings.media.AbstractMediaManager
      extended by com.threerings.media.sprite.SpriteManager
All Implemented Interfaces:
MediaConstants

public class SpriteManager
extends AbstractMediaManager

The sprite manager manages the sprites running about in the game.


Field Summary
protected  SortableArrayList<Sprite> _sprites
           
 
Fields inherited from class com.threerings.media.AbstractMediaManager
_host, _media, _notify, _remgr, _tickpos, _tickStamp, RENDER_ORDER
 
Fields inherited from interface com.threerings.media.MediaConstants
ALL, BACK, FRONT
 
Constructor Summary
SpriteManager()
           
 
Method Summary
 void addSprite(Sprite sprite)
          Add a sprite to the set of sprites managed by this manager.
protected  SortableArrayList<? extends AbstractMedia> createMediaList()
          Type safety jockeying.
 Iterator<Sprite> enumerateSprites()
          Returns an iterator over our managed sprites.
 Sprite getHighestHitSprite(int x, int y)
          Finds the sprite with the highest render order that hits the specified pixel.
 void getHitSprites(List<Sprite> list, int x, int y)
          When an animated view is determining what entity in its view is under the mouse pointer, it may require a list of sprites that are "hit" by a particular pixel.
 void getIntersectingSprites(List<Sprite> list, Shape shape)
          When an animated view processes its dirty rectangles, it may require an expansion of the dirty region which may in turn require the invalidation of more sprites than were originally invalid.
 List<Sprite> getSprites()
          Returns a list of all sprites registered with the sprite manager.
 void removeSprite(Sprite sprite)
          Removes the specified sprite from the set of sprites managed by this manager.
 void removeSprites(Predicate<Sprite> pred)
          Removes all sprites that match the supplied predicate.
 void renderSpritePaths(Graphics2D gfx)
          Render the sprite paths to the given graphics context.
 
Methods inherited from class com.threerings.media.AbstractMediaManager
clearMedia, createGraphics, dispatchNotifications, fastForward, getRegionManager, init, insertMedia, isManaged, paint, queueNotification, removeMedia, renderOrderDidChange, tick, tickAllMedia, tickMedia, viewLocationDidChange, willPaint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sprites

protected SortableArrayList<Sprite> _sprites
Constructor Detail

SpriteManager

public SpriteManager()
Method Detail

getIntersectingSprites

public void getIntersectingSprites(List<Sprite> list,
                                   Shape shape)
When an animated view processes its dirty rectangles, it may require an expansion of the dirty region which may in turn require the invalidation of more sprites than were originally invalid. In such cases, the animated view can call back to the sprite manager, asking it to append the sprites that intersect a particular region to the given list.

Parameters:
list - the list to fill with any intersecting sprites.
shape - the shape in which we have interest.

getHitSprites

public void getHitSprites(List<Sprite> list,
                          int x,
                          int y)
When an animated view is determining what entity in its view is under the mouse pointer, it may require a list of sprites that are "hit" by a particular pixel. The sprites' bounds are first checked and sprites with bounds that contain the supplied point are further checked for a non-transparent at the specified location.

Parameters:
list - the list to fill with any intersecting sprites, the sprites with the highest render order provided first.
x - the x (screen) coordinate to be checked.
y - the y (screen) coordinate to be checked.

getHighestHitSprite

public Sprite getHighestHitSprite(int x,
                                  int y)
Finds the sprite with the highest render order that hits the specified pixel.

Parameters:
x - the x (screen) coordinate to be checked
y - the y (screen) coordinate to be checked
Returns:
the highest sprite hit

addSprite

public void addSprite(Sprite sprite)
Add a sprite to the set of sprites managed by this manager.

Parameters:
sprite - the sprite to add.

getSprites

public List<Sprite> getSprites()
Returns a list of all sprites registered with the sprite manager. The returned list is immutable, sprites should be added or removed using addSprite(com.threerings.media.sprite.Sprite) or removeSprite(com.threerings.media.sprite.Sprite).


enumerateSprites

public Iterator<Sprite> enumerateSprites()
Returns an iterator over our managed sprites. Do not call Iterator.remove().


removeSprite

public void removeSprite(Sprite sprite)
Removes the specified sprite from the set of sprites managed by this manager.

Parameters:
sprite - the sprite to remove.

removeSprites

public void removeSprites(Predicate<Sprite> pred)
Removes all sprites that match the supplied predicate.


renderSpritePaths

public void renderSpritePaths(Graphics2D gfx)
Render the sprite paths to the given graphics context.

Parameters:
gfx - the graphics context.

createMediaList

protected SortableArrayList<? extends AbstractMedia> createMediaList()
Description copied from class: AbstractMediaManager
Type safety jockeying.

Specified by:
createMediaList in class AbstractMediaManager