|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpulpcore.sprite.Sprite
public abstract class Sprite
The superclass of all sprites. Contains location, dimension, alpha,
angle, visibility, and anchor information.
The Sprite does no drawing - subclasses implement the
drawSprite(CoreGraphics)
method to draw.
| Field Summary | |
|---|---|
Int |
alpha
The alpha of this Sprite, in range from 0 to 255. |
Fixed |
angle
The angle of this Sprite, typically in range from 0 to CoreMath.TWO_PI, although the angle can
have any value. |
static int |
CENTER
Constant for positioning the anchor point in the center of the sprite. |
static int |
DEFAULT
Constant for positioning the anchor point at the "default" location of the Sprite, which is usually its upper-left corner. |
static int |
EAST
Constant for positioning the anchor point in the right center of the sprite. |
Bool |
enabled
The flag indicating whether this Sprite is enabled. |
Fixed |
height
The height of this Sprite. |
static int |
NORTH
Constant for positioning the anchor point in the upper center of the sprite. |
static int |
NORTH_EAST
Constant for positioning the anchor point in the upper right corner of the sprite. |
static int |
NORTH_WEST
Constant for positioning the anchor point in the upper left corner of the sprite. |
Bool |
pixelSnapping
Sets whether pixel snapping enabled for rendering this Sprite. |
static int |
SOUTH
Constant for positioning the anchor point in the lower center of the sprite. |
static int |
SOUTH_EAST
Constant for positioning the anchor point in the lower right corner of the sprite. |
static int |
SOUTH_WEST
Constant for positioning the anchor point in the lower left corner of the sprite. |
Bool |
visible
The flag indicating whether or not this Sprite is visible. |
static int |
WEST
Constant for positioning the anchor point in the left center of the sprite. |
Fixed |
width
The width of this Sprite. |
Fixed |
x
The x location of this Sprite. |
Fixed |
y
The y location of this Sprite. |
| Constructor Summary | |
|---|---|
Sprite(double x,
double y,
double width,
double height)
|
|
Sprite(int x,
int y,
int width,
int height)
|
|
| Method Summary | |
|---|---|
void |
bindLocationTo(Sprite sprite)
Binds this sprite's location to that of the specified sprite. |
void |
bindSizeTo(Sprite sprite)
Binds this sprite's size to that of the specified sprite. |
void |
clearCursor()
Clears the cursor for this Sprite, so that it's parent cursor is used. |
void |
clearDirtyRect()
For dirty rectangles - most apps will not need ot call this method directly. |
boolean |
contains(int viewX,
int viewY)
Checks if the specified location is within the bounds of this Sprite. |
void |
draw(CoreGraphics g)
|
protected abstract void |
drawSprite(CoreGraphics g)
Draws the sprite. |
int |
getAnchor()
|
protected int |
getAnchorX()
|
protected int |
getAnchorY()
|
BlendMode |
getBlendMode()
|
int |
getCursor()
Gets the cursor for this Sprite. |
Rect |
getDirtyRect()
For dirty rectangles - most apps will not need ot call this method directly. |
double |
getLocalX(double viewX,
double viewY)
Gets the integer x-coordinate in Local Space of the specified location in View Space. |
double |
getLocalY(double viewX,
double viewY)
Gets the integer y-coordinate in Local Space of the specified location in View Space. |
protected int |
getNaturalHeight()
|
protected int |
getNaturalWidth()
|
Group |
getParent()
Gets this Sprite's parent Group, or null if this Sprite does not have a parent. |
boolean |
getPixelLevelChecks()
Returns true if this sprite should use pixel-level checks for intersections and picking. |
Group |
getRoot()
Gets this Sprite's oldest ancestor Group, or null if this Sprite does not have a parent. |
Scene2D |
getScene2D()
Gets the Scene2D this Sprite belongs to, or null if
this Sprite is not in a Scene2D. |
double |
getViewX()
Gets the x-coordinate of this sprite in View Space. |
double |
getViewX(double localX,
double localY)
Gets the x-coordinate in View Space of the specified location in Local Space. |
double |
getViewY()
Gets the y-coordinate of this sprite in View Space. |
double |
getViewY(double localX,
double localY)
Gets the y-coordinate in View Space of the specified location in Local Space. |
boolean |
intersects(Sprite sprite)
Checks if the specified sprite intersects this sprite. |
boolean |
isDirty()
Returns true if the Sprite's properties have changed since the last call to draw() |
boolean |
isEnabled()
Returns true if this Sprite's enabled property is set to true and its parent, if any, is enabled. |
boolean |
isEnabledAndVisible()
Returns true if this Sprite's enabled property is set to true, its visible property set to true, its alpha property is greater than zero, and its parent, if any, is enabled and visible. |
boolean |
isMouseDoubleClicked()
Checks if this Sprite (and its parents) are enabled, the primary mouse button was double-clicked since the last update, and the double-click occurred within this Sprite's bounds. |
boolean |
isMouseDown()
Checks if this Sprite (and its parents) are enabled, the mouse is currently within the bounds of this Sprite, and the primary mouse button is pressed down. |
boolean |
isMouseHover()
Checks if this Sprite (and its parents) are enabled, the mouse is within the bounds of this Sprite, and the primary mouse button is not pressed down. |
boolean |
isMouseOver()
Checks if this Sprite (and its parents) are enabled, and the mouse is currently within the bounds of this Sprite. |
boolean |
isMousePressed()
Checks if this Sprite (and its parents) are enabled, the primary mouse button was pressed since the last update, and the press occurred within this Sprite's bounds. |
boolean |
isMouseReleased()
Checks if this Sprite (and its parents) are enabled, the primary mouse button was released since the last update, and the release occurred within this Sprite's bounds. |
boolean |
isMouseTripleClicked()
Checks if this Sprite (and its parents) are enabled, the primary mouse button was triple-clicked since the last update, and the triple-click occurred within this Sprite's bounds. |
boolean |
isMouseWheelRotated()
Checks if this Sprite (and its parents) are enabled and the mouse wheel was rotated over this Sprite. |
boolean |
isPick(int viewX,
int viewY)
Checks if the specified location is within the bounds of this Sprite and this Sprite is the top-most Sprite at that location. |
boolean |
isPickEnabledAndVisible(int viewX,
int viewY)
Checks if the specified location is within the bounds of this Sprite and this Sprite is the top-most visible and enabled Sprite at that location. |
protected boolean |
isTransparent(int localX,
int localY)
Checks if the pixel at the specified integer location is transparent. |
void |
move(double startX,
double startY,
double endX,
double endY,
int duration)
|
void |
move(double startX,
double startY,
double endX,
double endY,
int duration,
Easing easing)
|
void |
move(double startX,
double startY,
double endX,
double endY,
int duration,
Easing easing,
int startDelay)
|
void |
move(int startX,
int startY,
int endX,
int endY,
int duration)
|
void |
move(int startX,
int startY,
int endX,
int endY,
int duration,
Easing easing)
|
void |
move(int startX,
int startY,
int endX,
int endY,
int duration,
Easing easing,
int startDelay)
|
void |
moveTo(double x,
double y,
int duration)
|
void |
moveTo(double x,
double y,
int duration,
Easing easing)
|
void |
moveTo(double x,
double y,
int duration,
Easing easing,
int startDelay)
|
void |
moveTo(int x,
int y,
int duration)
|
void |
moveTo(int x,
int y,
int duration,
Easing easing)
|
void |
moveTo(int x,
int y,
int duration,
Easing easing,
int startDelay)
|
void |
propertyChange(Property property)
On a property change this Sprite is marked as dirty. |
void |
scale(double width1,
double height1,
double width2,
double height2,
int duration)
|
void |
scale(double width1,
double height1,
double width2,
double height2,
int duration,
Easing easing)
|
void |
scale(double width1,
double height1,
double width2,
double height2,
int duration,
Easing easing,
int startDelay)
|
void |
scale(int width1,
int height1,
int width2,
int height2,
int duration)
|
void |
scale(int width1,
int height1,
int width2,
int height2,
int duration,
Easing easing)
|
void |
scale(int width1,
int height1,
int width2,
int height2,
int duration,
Easing easing,
int startDelay)
|
void |
scaleTo(double width,
double height,
int duration)
|
void |
scaleTo(double width,
double height,
int duration,
Easing easing)
|
void |
scaleTo(double width,
double height,
int duration,
Easing easing,
int startDelay)
|
void |
scaleTo(int width,
int height,
int duration)
|
void |
scaleTo(int width,
int height,
int duration,
Easing easing)
|
void |
scaleTo(int width,
int height,
int duration,
Easing easing,
int startDelay)
|
void |
setAnchor(int anchor)
Sets the anchor of this Sprite. |
void |
setBlendMode(BlendMode blendMode)
Sets the blend mode used to draw this Sprite. |
void |
setCursor(int cursor)
Sets the cursor for this Sprite. |
void |
setDirty(boolean dirty)
Marks this Sprite as dirty, which will force it to redraw on the next frame. |
void |
setLocation(double x,
double y)
Sets the location of this Sprite. |
void |
setLocation(int x,
int y)
Sets the location of this Sprite. |
void |
setSize(double width,
double height)
Sets the size of this Sprite. |
void |
setSize(int width,
int height)
Sets the size of this Sprite. |
void |
translate(double x,
double y)
Translates the location of this Sprite. |
void |
translate(int x,
int y)
Translates the location of this Sprite. |
void |
update(int elapsedTime)
Updates all of this Sprite's properties. |
boolean |
updateDirtyRect()
For dirty rectangles - most apps will not need ot call this method directly. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT
public static final int NORTH
public static final int SOUTH
public static final int WEST
public static final int EAST
public static final int NORTH_WEST
public static final int NORTH_EAST
public static final int SOUTH_WEST
public static final int SOUTH_EAST
public static final int CENTER
public final Bool enabled
public final Fixed x
public final Fixed y
public final Fixed width
public final Fixed height
public final Fixed angle
CoreMath.TWO_PI, although the angle can
have any value. The Sprite is rotated around its anchor.
public final Int alpha
public final Bool visible
public final Bool pixelSnapping
Enabling pixel snapping may allow some type of images (e.g. pixel art) to look better.
This value is false by default.
| Constructor Detail |
|---|
public Sprite(int x,
int y,
int width,
int height)
public Sprite(double x,
double y,
double width,
double height)
| Method Detail |
|---|
public final Group getParent()
public final Group getRoot()
public Scene2D getScene2D()
Scene2D this Sprite belongs to, or null if
this Sprite is not in a Scene2D.
public final boolean isEnabled()
public final boolean isEnabledAndVisible()
public void propertyChange(Property property)
propertyChange in interface PropertyListenerproperty - the property whose value has changed.public final Rect getDirtyRect()
public final boolean updateDirtyRect()
public final void clearDirtyRect()
public final void setDirty(boolean dirty)
public final boolean isDirty()
protected int getNaturalWidth()
protected int getNaturalHeight()
protected int getAnchorX()
protected int getAnchorY()
public final void setAnchor(int anchor)
DEFAULT,
NORTH, SOUTH, WEST, EAST,
NORTH_WEST, SOUTH_WEST, NORTH_EAST, SOUTH_EAST, or
CENTER.
NW N NE
+----+----+
| |
W + * + E
| |
+----+----+
SW S SE
The DEFAULT anchor is equivilant to NORTH_WEST for most Sprites (except
for ImageSprites, which use the CoreImage's hotspot as the anchor).
public final int getAnchor()
public final void setCursor(int cursor)
Scene2D.
Input,
getCursor(),
clearCursor()public final void clearCursor()
Input,
getCursor(),
setCursor(int)public final int getCursor()
Input,
setCursor(int),
clearCursor()public final void setBlendMode(BlendMode blendMode)
BlendModepublic final BlendMode getBlendMode()
public void update(int elapsedTime)
public final void draw(CoreGraphics g)
protected abstract void drawSprite(CoreGraphics g)
public final double getLocalX(double viewX,
double viewY)
public final double getLocalY(double viewX,
double viewY)
public final double getViewX()
public final double getViewY()
public final double getViewX(double localX,
double localY)
public final double getViewY(double localX,
double localY)
public final boolean contains(int viewX,
int viewY)
viewX - x-coordinate in view spaceviewY - y-coordinate in view space
public boolean getPixelLevelChecks()
This method returns false. Subclasses of Sprite should override this method if they
have pixel-level checks in their implementation of isTransparent(int, int).
protected boolean isTransparent(int localX,
int localY)
The default implementation always returns false. Subclasses of this class may need to override this method to return accurate results.
This method is called from contains(int,int).
localX - integer x-coordinate in local spacelocalY - integer y-coordinate in local space
public final boolean isPick(int viewX,
int viewY)
viewX - x-coordinate in view spaceviewY - y-coordinate in view space
public final boolean isPickEnabledAndVisible(int viewX,
int viewY)
viewX - x-coordinate in view spaceviewY - y-coordinate in view spacepublic boolean intersects(Sprite sprite)
The two sprites do no have to be in the same Group.
sprite - the sprite to test against.
public boolean isMouseOver()
For a typical button UI button behavior, use Button.
public boolean isMouseHover()
For a typical button UI button behavior, use Button.
public boolean isMouseDown()
For a typical button UI button behavior, use Button.
public boolean isMousePressed()
For a typical button UI button behavior, use Button.
public boolean isMouseReleased()
For a typical button UI button behavior, use Button.
public boolean isMouseDoubleClicked()
For a typical button UI button behavior, use Button.
public boolean isMouseTripleClicked()
For a typical button UI button behavior, use Button.
public boolean isMouseWheelRotated()
public void setLocation(int x,
int y)
public void setLocation(double x,
double y)
public void translate(int x,
int y)
public void translate(double x,
double y)
public void setSize(int width,
int height)
public void setSize(double width,
double height)
public void bindLocationTo(Sprite sprite)
public void bindSizeTo(Sprite sprite)
public void move(int startX,
int startY,
int endX,
int endY,
int duration)
public void move(int startX,
int startY,
int endX,
int endY,
int duration,
Easing easing)
public void move(int startX,
int startY,
int endX,
int endY,
int duration,
Easing easing,
int startDelay)
public void moveTo(int x,
int y,
int duration)
public void moveTo(int x,
int y,
int duration,
Easing easing)
public void moveTo(int x,
int y,
int duration,
Easing easing,
int startDelay)
public void move(double startX,
double startY,
double endX,
double endY,
int duration)
public void move(double startX,
double startY,
double endX,
double endY,
int duration,
Easing easing)
public void move(double startX,
double startY,
double endX,
double endY,
int duration,
Easing easing,
int startDelay)
public void moveTo(double x,
double y,
int duration)
public void moveTo(double x,
double y,
int duration,
Easing easing)
public void moveTo(double x,
double y,
int duration,
Easing easing,
int startDelay)
public void scale(int width1,
int height1,
int width2,
int height2,
int duration)
public void scale(int width1,
int height1,
int width2,
int height2,
int duration,
Easing easing)
public void scale(int width1,
int height1,
int width2,
int height2,
int duration,
Easing easing,
int startDelay)
public void scaleTo(int width,
int height,
int duration)
public void scaleTo(int width,
int height,
int duration,
Easing easing)
public void scaleTo(int width,
int height,
int duration,
Easing easing,
int startDelay)
public void scale(double width1,
double height1,
double width2,
double height2,
int duration)
public void scale(double width1,
double height1,
double width2,
double height2,
int duration,
Easing easing)
public void scale(double width1,
double height1,
double width2,
double height2,
int duration,
Easing easing,
int startDelay)
public void scaleTo(double width,
double height,
int duration)
public void scaleTo(double width,
double height,
int duration,
Easing easing)
public void scaleTo(double width,
double height,
int duration,
Easing easing,
int startDelay)
|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||