|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpulpcore.sprite.Sprite
pulpcore.sprite.ImageSprite
public class ImageSprite
An image-based sprite. The image can be an AnimatedImage.
The anchor of an ImageSprite is automatically set to the image's hotspot.
To ignore the hotspot, use Sprite.setAnchor(double, double).
By default, ImageSprites use pixel-level checking for intersection tests. Use
setPixelLevelChecks(boolean) to disable this feature.
If you change the pixels of this ImageSprite's CoreImage, call
sprite.setDirty(true).
| Field Summary | |
|---|---|
Bool |
antiAlias
Flag indicating whether the edges of this ImageSprite are anti-aliased when rotating or drawing at fractional locations. |
| Fields inherited from class pulpcore.sprite.Sprite |
|---|
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y |
| Constructor Summary | |
|---|---|
ImageSprite(CoreImage image,
double x,
double y)
Creates an ImageSprite that has the same dimensions as the image. |
|
ImageSprite(CoreImage image,
double x,
double y,
double w,
double h)
Creates an ImageSprite that draws the image scaled to the specified dimensions. |
|
ImageSprite(CoreImage image,
int x,
int y)
Creates an ImageSprite that has the same dimensions as the image. |
|
ImageSprite(CoreImage image,
int x,
int y,
int w,
int h)
Creates an ImageSprite that draws the image scaled to the specified dimensions. |
|
ImageSprite(String imageAsset,
double x,
double y)
Creates an ImageSprite that has the same dimensions as the image. |
|
ImageSprite(String imageAsset,
double x,
double y,
double w,
double h)
Creates an ImageSprite that draws the image scaled to the specified dimensions. |
|
ImageSprite(String imageAsset,
int x,
int y)
Creates an ImageSprite that has the same dimensions as the image. |
|
ImageSprite(String imageAsset,
int x,
int y,
int w,
int h)
Creates an ImageSprite that draws the image scaled to the specified dimensions. |
|
| Method Summary | |
|---|---|
protected void |
drawSprite(CoreGraphics g)
Draws the sprite. |
CoreImage |
getImage()
Gets this ImageSprite's internal image. |
protected int |
getNaturalHeight()
Gets the fixed-point value of the Sprite's natural height. |
protected int |
getNaturalWidth()
Gets the fixed-point value of the Sprite's natural width. |
boolean |
getPixelLevelChecks()
Returns true if this sprite should use pixel-level checks for intersections and picking. |
boolean |
isOpaque()
Returns true if this Sprite is opaque. |
protected boolean |
isTransparent(int localX,
int localY)
Checks if the pixel at the specified integer location is transparent. |
void |
propertyChange(Property p)
On a property change this Sprite is marked as dirty. |
void |
setAnchor(int anchor)
Deprecated. Compass directions are being phased out - Use Sprite.setAnchor(double, double) or setAnchorToHotSpot() instead. |
void |
setAnchorToHotSpot()
Sets the anchor to the underlying image's hotspot. |
void |
setImage(CoreImage image)
Sets this ImageSprite's internal image. |
void |
setImage(String imageAsset)
Sets this ImageSprite's internal image. |
void |
setPixelLevelChecks(boolean pixelLevel)
Sets whether this sprite should use pixel-level checking for intersections and picking. |
void |
update(int elapsedTime)
Updates all of this Sprite's properties. |
| Methods inherited from class pulpcore.sprite.Sprite |
|---|
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isPick, isPickEnabledAndVisible, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final Bool antiAlias
true.
| Constructor Detail |
|---|
public ImageSprite(String imageAsset,
int x,
int y)
public ImageSprite(CoreImage image,
int x,
int y)
public ImageSprite(String imageAsset,
int x,
int y,
int w,
int h)
public ImageSprite(CoreImage image,
int x,
int y,
int w,
int h)
public ImageSprite(String imageAsset,
double x,
double y)
public ImageSprite(CoreImage image,
double x,
double y)
public ImageSprite(String imageAsset,
double x,
double y,
double w,
double h)
public ImageSprite(CoreImage image,
double x,
double y,
double w,
double h)
| Method Detail |
|---|
public boolean isOpaque()
SpriteReturns false by default.
isOpaque in class Spritepublic final CoreImage getImage()
public void setImage(String imageAsset)
public void setImage(CoreImage image)
public void setAnchor(int anchor)
Sprite.setAnchor(double, double) or setAnchorToHotSpot() instead.
Sprite.DEFAULT,
Sprite.NORTH, Sprite.SOUTH, Sprite.WEST, Sprite.EAST,
Sprite.NORTH_WEST, Sprite.SOUTH_WEST, Sprite.NORTH_EAST, Sprite.SOUTH_EAST, or
Sprite.CENTER.
NW N NE
+----+----+
| |
W + * + E
| |
+----+----+
SW S SE
The Sprite.DEFAULT anchor is equivalent to Sprite.NORTH_WEST for most Sprites (except
for ImageSprites, which use the CoreImage's hotspot as the anchor).
If the anchor is set to Sprite.DEFAULT, this method
calls setAnchorToHotSpot().
setAnchor in class Spritepublic void setAnchorToHotSpot()
public void update(int elapsedTime)
Sprite
update in class Spritepublic void propertyChange(Property p)
Sprite
propertyChange in interface PropertyListenerpropertyChange in class Spritep - the property whose value has changed.public final void setPixelLevelChecks(boolean pixelLevel)
public final boolean getPixelLevelChecks()
getPixelLevelChecks in class SpritesetPixelLevelChecks(boolean)protected int getNaturalWidth()
SpriteImageSprite, the natural width is the
width of the image.
getNaturalWidth in class Spriteprotected int getNaturalHeight()
SpriteImageSprite, the natural height is the
height of the image.
getNaturalHeight in class Sprite
protected boolean isTransparent(int localX,
int localY)
SpriteThe default implementation always returns false. Subclasses of this class may need to override this method to return accurate results.
This method is called from Sprite.contains(int,int).
isTransparent in class SpritelocalX - integer x-coordinate in local spacelocalY - integer y-coordinate in local spaceprotected void drawSprite(CoreGraphics g)
SpriteThis method may be called multiple times for each dirty rectangle. The clip of the graphics context will be set to the current dirty rectangle.
When the contents of this sprite change (in another words, the graphic output of this method
will be different from the last time it is called), subclasses should call
setDirty(true).
Implementors should not save a reference to the graphics context as it can change between calls to this method.
drawSprite in class Sprite
|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||