|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.lcdui.game.Layer
javax.microedition.lcdui.game.Sprite
Description:
Sprite Frames:
Field Summary | |
static int |
TRANMIRROR
|
static int |
TRANMIRROR_ROT180
|
static int |
TRANMIRROR_ROT270
|
static int |
TRANMIRROR_ROT90
|
static int |
TRANNONE
|
static int |
TRANROT180
|
static int |
TRANROT270
|
static int |
TRANROT90
|
Constructor Summary | |
Sprite(Image image)
Creates a new non-animated Sprite using the provided Image. |
|
Sprite(Image image,
int frameWidth,
int frameHeight)
Creates a new animated Sprite using frames contained in the provided Image. |
|
Sprite(Sprite s)
Creates a new Sprite from another Sprite. |
Method Summary | |
boolean |
collidesWith(Image image,
int x,
int y,
boolean pixelLevel)
Checks for a collision between this Sprite and the image specified located at (x, y). |
boolean |
collidesWith(Sprite s,
boolean pixelLevel)
Checks for a collision between this Sprite and the specified Sprite. |
boolean |
collidesWith(TiledLayer t,
boolean pixelLevel)
Checks for a collision between this Sprite and the specified TiledBackground. |
void |
defineCollisionRectangle(int x,
int y,
int width,
int height)
Defines the Sprite’s bounding rectangle that is used for collision detection purposes. |
void |
defineReferencePixel(int x,
int y)
Defines the location of the reference point within this Sprite. |
int |
getFrame()
Gets the current frame in the frame sequence. |
int |
getFrameSequenceLength()
Gets the number of elements in the frame sequence. |
int |
getRawFrameCount()
Gets the number of raw frames for this Sprite. |
int |
getRefPixelX()
Gets the horizontal location of this Sprite’s reference point. |
int |
getRefPixelY()
Gets the vertical location of this Sprite’s reference point. |
void |
nextFrame()
Selects the next frame in the frame sequence. |
void |
paint(Graphics g)
Draws the Sprite. |
void |
prevFrame()
Selects the next frame in the frame sequence. |
void |
setFrame(int sequenceIndex)
Selects current frame in the frame sequence. |
void |
setFrameSequence(int[] sequence)
Set the frame sequence for this Sprite. |
void |
setImage(Image image,
int frameWidth,
int frameHeight)
Changes the image used for the Sprite. |
void |
setRefPixelPosition(int x,
int y)
Sets this Sprite’s position such that its reference point is located at (x,y), accounting for any transform that may be in effect. |
void |
setTransform(int transform)
Sets the transformation for this Sprite. |
Methods inherited from class javax.microedition.lcdui.game.Layer |
getHeight, getWidth, getX, getY, isVisible, move, setPosition, setVisible |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TRANNONE
public static final int TRANROT180
public static final int TRANROT270
public static final int TRANROT90
public static final int TRANMIRROR
public static final int TRANMIRROR_ROT180
public static final int TRANMIRROR_ROT270
public static final int TRANMIRROR_ROT90
Constructor Detail |
public Sprite(Image image)
image
- The Image to use as the single frame for the Sprite
java.lang.NullPointerException
- if image is nullpublic Sprite(Image image, int frameWidth, int frameHeight)
By default, the Sprite is visible and positioned at (0,0).
image
- Image to use for SpriteframeWidth
- width, in pixels, of the individual raw framesframeHeight
- height, in pixels, of the individual raw frames
java.lang.NullPointerException
- if image is null
java.lang.IllegalArgumentException
- if frameHeight or frameWidth is less than 1
java.lang.IllegalArgumentException
- if the image width is not an integer multiple of the frameWidth
java.lang.IllegalArgumentException
- if the image height is not an integer multiple of the frameHeightpublic Sprite(Sprite s)
s
- Sprite to create a copy of
java.lang.NullPointerException
- if s is nullMethod Detail |
public final boolean collidesWith(Sprite s, boolean pixelLevel)
Pixel-level detection is @@@.
s
- The Sprite to test for collision withpixelLevel
- True to test for collision on a pixel-by-pixel basis, false to test using simple bounds
checking.
public final boolean collidesWith(Image image, int x, int y, boolean pixelLevel)
Pixel-level detection is @@@.
image
- The image to test for collision withx
- x coordinate of imagey
- y coordinate of imagepixelLevel
- True to test for collision on a pixel-by-pixel basis, false to test using simple bounds
checking.
public final boolean collidesWith(TiledLayer t, boolean pixelLevel)
If pixel-level detection is not used, this method simply checks if the Sprite’s collision rectangle intersects with a non-empty cell in the TiledLayer.
Any transformation applied to the Sprite is automatically accounted for.
t
- The TiledLayer to test for collision withpixelLevel
- True to test for collision on a pixel-by-pixel basis, false to test using simple bounds
checking against non-empty cells.
public void defineReferencePixel(int x, int y)
By default, a Sprite’s reference point is located at (0,0); that is, the upper-left corner of the Sprite. Changing the location of the reference point does not change the Sprite’s physical position in the game. However, subsequent calls to methods that use the reference point will be impacted by its new location.
x
- The horizontal location of the reference point, relative to the left edge of the Sprite.y
- The vertical location of the reference point, relative to the top edge of the Sprite.public final int getFrame()
public int getFrameSequenceLength()
public int getRawFrameCount()
public int getRefPixelX()
public int getRefPixelY()
public void nextFrame()
public final void paint(Graphics g)
Rendering is subject to the clip region of the Graphics object. The Sprite will be drawn only if it is visible.
paint
in class Layer
g
- Graphics object to draw Sprite on
java.lang.NullPointerException
- if g is nullpublic void prevFrame()
public void defineCollisionRectangle(int x, int y, int width, int height)
x
- The horizontal location of the collision rectangle relative to the Sprite’s left edgey
- The vertical location of the collision rectangle relative to the Sprite’s top edgewidth
- The width of the collision rectangleheight
- The height of the collision rectangle
java.lang.IllegalArgumentException
- if the specified width or height is less than 0public void setFrame(int sequenceIndex)
sequenceIndex
- Index of of the desired entry in the frame sequence
java.lang.IndexOutOfBoundsException
- if frameIndex is less than 0
java.lang.IndexOutOfBoundsException
- if frameIndex is equal to or greater than the length of the
current frame sequence (or the number of raw frames for the default sequence)public void setFrameSequence(int[] sequence)
sequence
- An array of integers, where each integer represents a frame index
java.lang.ArrayIndexOutOfBoundsException
- if seq is non-null and any member of the array has a
value less than 0 or greater than or equal to the number of frames as reported by
getRawFrameCount()
java.lang.IllegalArgumentException
- if the array has less than 1 elementpublic void setImage(Image image, int frameWidth, int frameHeight)
If the new frame set has as many or more raw frames than the previous frame set, then:
If the new frame set has less frames than the previous frame set, then:
image
- Image to use for SpriteframeWidth
- The width, in pixels, of the individual raw framesframeHeight
- The height, in pixels, of the individual raw frames
java.lang.NullPointerException
- if image is null
java.lang.IllegalArgumentException
- if frameHeight or frameWidth is less than 1
java.lang.IllegalArgumentException
- if the image width is not an integer multiple of the frameWidth
java.lang.IllegalArgumentException
- if the image height is not an integer multiple of the frameHeightpublic void setRefPixelPosition(int x, int y)
x
- The horizontal location of the reference pointy
- The vertical location of the reference pointpublic void setTransform(int transform)
By default, a Sprite’s transform is TRANSFORM_NONE.
All transforms are performed around the Sprite’s reference point. Thus, the reference point does not move as a result of changing the Sprite’s transform.
transform
- The desired transform for this Sprite
java.lang.IllegalArgumentException
- if the requested transform is invalid or unknown
|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2006 BenQ Mobile GmbH & Co. OHG or respective copyright owner. All Rights Reserved. BenQ Corp. is a trademark licensee of Siemens AG. |
For further information about Mobility Toolkit (MTK) visit our Developer Portal. |