public class ImageSprite extends Sprite
hitTest(int, int) only
reports a hit if the specified point is within a non-transparent pixel
for the sprite's current image frame.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_FRAME_RATE
Default frame rate.
|
static int |
MOVEMENT_CUED
Animation mode indicating movement cued animation.
|
static int |
NO_ANIMATION
Animation mode indicating no animation.
|
static int |
TIME_BASED
Animation mode indicating time based animation.
|
static int |
TIME_SEQUENTIAL
Animation mode indicating sequential progressive animation.
|
HUD_LAYERCARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST| Constructor and Description |
|---|
ImageSprite()
Constructs an image sprite without any associated frames and with an invalid default initial
location.
|
ImageSprite(Mirage image)
Constructs an image sprite that will display the supplied single image when rendering itself.
|
ImageSprite(MultiFrameImage frames)
Constructs an image sprite.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hitTest(int x,
int y)
Returns true if the sprite's bounds contain the specified point, and if there is a
non-transparent pixel in the sprite's image at the specified point, false if not.
|
void |
layout()
Instructs this sprite to lay out its current frame and any accoutrements.
|
void |
paint(Graphics2D gfx)
Called by the appropriate manager to request that the media render itself with the given
graphics context.
|
void |
setAnimationMode(int mode)
Sets the animation mode for this sprite.
|
void |
setFrameRate(float fps)
Sets the number of frames per second desired for the sprite animation.
|
void |
setFrames(MultiFrameImage frames)
Set the image array used to render the sprite.
|
void |
setMirage(Mirage mirage)
Set the image to be used for this sprite.
|
void |
tick(long timestamp)
Called periodically by this media's manager to give it a chance to do its thing.
|
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, inside, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, setOrientation, viewLocationDidChangecontains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, queueNotification, renderCompareTo, setRenderOrder, toStringpublic static final int DEFAULT_FRAME_RATE
public static final int NO_ANIMATION
public static final int MOVEMENT_CUED
public static final int TIME_BASED
public static final int TIME_SEQUENTIAL
public ImageSprite()
setFrames(com.threerings.media.util.MultiFrameImage), and its location updated with
AbstractMedia.setLocation(int, int).public ImageSprite(MultiFrameImage frames)
frames - the multi-frame image used to display the sprite.public ImageSprite(Mirage image)
public boolean hitTest(int x,
int y)
public void setAnimationMode(int mode)
TIME_BASED: cues the animation based on a target
frame rate (specified via setFrameRate(float)).MOVEMENT_CUED: ticks the animation to the next
frame every time the sprite is moved along its path.NO_ANIMATION:
disables animation.mode - the desired animation mode.public void setFrameRate(float fps)
TIME_BASED.fps - the desired frames per second.public void setMirage(Mirage mirage)
public void setFrames(MultiFrameImage frames)
frames - the sprite images.public void layout()
public void paint(Graphics2D gfx)
AbstractMediapublic void tick(long timestamp)
AbstractMediatick in class Spritetimestamp - a time stamp associated with this tick. Note: this is not obtained
from a call to System.currentTimeMillis() and cannot be compared to timestamps
obtained there from.Copyright © 2015. All rights reserved.