Motorola C450 Manual De Usuario

Descargar
Página de 86
 
• 
public void setDepth(int d)
 – Set Sprite's depth order. The depth 
order is relative to other Sprites when multiple Sprites are contained in a container 
object, i.e. a PlayField. When Sprites are drawn explicitly instead of implicitly through 
the use of a container object, the management of drawing order is the responsibility 
of the developer. Integer.MIN_VALUE is the lowest depth, Integer.MAX_VALUE is 
the highest depth. So items with depth Integer.MIN_VALUE would be drawn first, or 
at the bottom, and items with depth Integer.MAX_VALUE would be drawn last or on 
top. 
• 
public void move(int dx, int dy)
 – Move Sprite. The method 
parameters are 
dx
 - pixels to move Sprite along horizontal axis, and 
dy
 - pixels to 
move Sprite along vertical axis.  
• 
public int getX()
 – Get Sprite's x position. 
• 
public int getY()
 – Get Sprite's y position. 
• 
public int getDepth() 
– Get Sprite's depth order. 
• 
public int getHeight()
 –  Get Sprite's height order. 
• 
public int getWidth()
 – Get Sprite's width in pixels. 
• 
public boolean collidesWith(Sprite s, 
boolean pixelLevel)
 throws 
NullPointerException
 – Check for 
collision between two Sprites. If 
pixelLevel
 is false, check for overlap in the 
rectangular areas of the two Sprites, using positions (x, y) and extents (width, height). 
The two Sprites are treated as if they are in the same coordinate system. For 
example, if the two Sprites are on different PlayFields that are drawn at different 
locations, this method still behaves as if they are on the same PlayField. If 
pixelLevel
 is true, check for overlap in opaque pixels of the two Sprites. 
Overlapping in transparent regions of either Sprite will not be considered a collision. 
• 
public void setFrame(int frame)
 – Set Sprite's animation frame. 
Sets which frame from the frame sequence to draw when draw(Graphics) is called. 
All Sprites have a default frame sequence as described in the constructor. 
• 
public int getFrame()
 – Get Sprite's current animation frame. All Sprites 
have a default frame sequence as described in the constructor. 
• 
public int getNumRawFrames() 
– Get the number of raw frames in 
the original frame set for this Sprite. 
• 
public void nextFrame()
 – Set current animation frame to the next 
frame. Advance to next frame in the frame sequence. All Sprites have a default frame 
sequence as described in the constructor. Frame list is considered to be circular, i.e. 
if 
nextFrame()
 is called when the last frame is the current frame, this will advance 
to the first frame. 
• 
public void prevFrame()
 – Set current animation frame to the previous 
frame. Advance to previous frame in the frame sequence. All Sprites have a default 
frame sequence as described in the constructor. Frame list is considered to be 
circular, i.e. if 
prevFrame()
 is called when the first frame is the current frame, this 
will advance to the last frame.