📄 sprite.html
字号:
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the horizontal location of the reference pixel, relative to the left edge of the un-transformed frame<DD><CODE>y</CODE> - the vertical location of the reference pixel, relative to the top edge of the un-transformed frame<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setRefPixelPosition(int, int)"><CODE>setRefPixelPosition(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelX()"><CODE>getRefPixelX()</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelY()"><CODE>getRefPixelY()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setRefPixelPosition(int, int)"><!-- --></A><H3>
setRefPixelPosition</H3>
<PRE>
public void <B>setRefPixelPosition</B>(int x, int y)</PRE>
<DL>
<DD>Sets this Sprite's position such that its reference pixel is located at (x,y) in the painter's coordinate system.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the horizontal location at which to place the reference pixel<DD><CODE>y</CODE> - the vertical location at which to place the reference pixel<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#defineReferencePixel(int, int)"><CODE>defineReferencePixel(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelX()"><CODE>getRefPixelX()</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelY()"><CODE>getRefPixelY()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getRefPixelX()"><!-- --></A><H3>
getRefPixelX</H3>
<PRE>
public int <B>getRefPixelX</B>()</PRE>
<DL>
<DD>Gets the horizontal position of this Sprite's reference pixel in the painter's coordinate system.<DD><DL>
<DT><B>Returns:</B><DD>the horizontal location of the reference pixel<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#defineReferencePixel(int, int)"><CODE>defineReferencePixel(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setRefPixelPosition(int, int)"><CODE>setRefPixelPosition(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelY()"><CODE>getRefPixelY()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getRefPixelY()"><!-- --></A><H3>
getRefPixelY</H3>
<PRE>
public int <B>getRefPixelY</B>()</PRE>
<DL>
<DD>Gets the vertical position of this Sprite's reference pixel in the painter's coordinate system.<DD><DL>
<DT><B>Returns:</B><DD>the vertical location of the reference pixel<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#defineReferencePixel(int, int)"><CODE>defineReferencePixel(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setRefPixelPosition(int, int)"><CODE>setRefPixelPosition(int, int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRefPixelX()"><CODE>getRefPixelX()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setFrame(int)"><!-- --></A><H3>
setFrame</H3>
<PRE>
public void <B>setFrame</B>(int sequenceIndex)</PRE>
<DL>
<DD>Selects the current frame in the frame sequence. <p> The current frame is rendered when <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#paint(javax.microedition.lcdui.Graphics)"><CODE>paint(Graphics)</CODE></A> is called. <p> The index provided refers to the desired entry in the frame sequence, not the index of the actual frame itself.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>sequenceIndex</CODE> - the index of of the desired entry in the frame sequence<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>frameIndex</code> is less than<code>0</code><DD><CODE><A HREF="../../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>frameIndex</code> is equal to or greater than the length of the current frame sequence (or the number of raw frames for the default sequence)<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getFrame()"><CODE>getFrame()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFrame()"><!-- --></A><H3>
getFrame</H3>
<PRE>
public final int <B>getFrame</B>()</PRE>
<DL>
<DD>Gets the current index in the frame sequence. <p> The index returned refers to the current entry in the frame sequence, not the index of the actual frame that is displayed.<DD><DL>
<DT><B>Returns:</B><DD>the current index in the frame sequence<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrame(int)"><CODE>setFrame(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getRawFrameCount()"><!-- --></A><H3>
getRawFrameCount</H3>
<PRE>
public int <B>getRawFrameCount</B>()</PRE>
<DL>
<DD>Gets the number of raw frames for this Sprite. The value returned reflects the number of frames; it does not reflect the length of the Sprite's frame sequence. However, these two values will be the same if the default frame sequence is used.<DD><DL>
<DT><B>Returns:</B><DD>the number of raw frames for this Sprite<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getFrameSequenceLength()"><CODE>getFrameSequenceLength()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFrameSequenceLength()"><!-- --></A><H3>
getFrameSequenceLength</H3>
<PRE>
public int <B>getFrameSequenceLength</B>()</PRE>
<DL>
<DD>Gets the number of elements in the frame sequence. The value returned reflects the length of the Sprite's frame sequence; it does not reflect the number of raw frames. However, these two values will be the same if the default frame sequence is used.<DD><DL>
<DT><B>Returns:</B><DD>the number of elements in this Sprite's frame sequence<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRawFrameCount()"><CODE>getRawFrameCount()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="nextFrame()"><!-- --></A><H3>
nextFrame</H3>
<PRE>
public void <B>nextFrame</B>()</PRE>
<DL>
<DD>Selects the next frame in the frame sequence. <p> The frame sequence is considered to be circular, i.e. if <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#nextFrame()"><CODE>nextFrame()</CODE></A> is called when at the end of the sequence, this method will advance to the first entry in the sequence.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#prevFrame()"><CODE>prevFrame()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="prevFrame()"><!-- --></A><H3>
prevFrame</H3>
<PRE>
public void <B>prevFrame</B>()</PRE>
<DL>
<DD>Selects the previous frame in the frame sequence. <p> The frame sequence is considered to be circular, i.e. if <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#prevFrame()"><CODE>prevFrame()</CODE></A> is called when at the start of the sequence, this method will advance to the last entry in the sequence.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#nextFrame()"><CODE>nextFrame()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="paint(javax.microedition.lcdui.Graphics)"><!-- --></A><H3>
paint</H3>
<PRE>
public final void <B>paint</B>(<A HREF="../../../../javax/microedition/lcdui/Graphics.html">Graphics</A> g)</PRE>
<DL>
<DD>Draws the Sprite. <P> Draws current frame of Sprite using the provided Graphics object. The Sprite's upper left corner is rendered at the Sprite's current position relative to the origin of the Graphics object. The current position of the Sprite's upper-left corner can be retrieved by calling <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getX()"><CODE>Layer.getX()</CODE></A> and <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getY()"><CODE>Layer.getY()</CODE></A>. <P> Rendering is subject to the clip region of the Graphics object. The Sprite will be drawn only if it is visible. <p> If the Sprite's Image is mutable, the Sprite is rendered using the current contents of the Image.<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="../../../../javax/microedition/lcdui/game/Layer.html#paint(javax.microedition.lcdui.Graphics)">paint</A></CODE> in class <CODE><A HREF="../../../../javax/microedition/lcdui/game/Layer.html">Layer</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>g</CODE> - the graphics object to draw <code>Sprite</code> on<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>g</code> is <code>null</code></DL>
</DD>
</DL>
<HR>
<A NAME="setFrameSequence(int[])"><!-- --></A><H3>
setFrameSequence</H3>
<PRE>
public void <B>setFrameSequence</B>(int[] sequence)</PRE>
<DL>
<DD>Set the frame sequence for this Sprite. <p> All Sprites have a default sequence that displays the Sprites frames in order. This method allows for the creation of an arbitrary sequence using the available frames. The current index in the frame sequence is reset to zero as a result of calling this method. <p> The contents of the sequence array are copied when this method is called; thus, any changes made to the array after this method returns have no effect on the Sprite's frame sequence. <P> Passing in <code>null</code> causes the Sprite to revert to the default frame sequence.<p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>sequence</CODE> - an array of integers, where each integer represents a frame index<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if seq is non-null and any member of the array has a value less than <code>0</code> or greater than or equal to the number of frames as reported by <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getRawFrameCount()"><CODE>getRawFrameCount()</CODE></A><DD><CODE><A HREF="../../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the array has less than <code>1</code> element<DT><B>See Also: </B><DD><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#nextFrame()"><CODE>nextFrame()</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#prevFrame()"><CODE>prevFrame()</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrame(int)"><CODE>setFrame(int)</CODE></A>,
<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#getFrame()"><CODE>getFrame()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setImage(javax.microedition.lcdui.Image, int, int)"><!-- --></A><H3>
setImage</H3>
<PRE>
public void <B>setImage</B>(<A HREF="../../../../javax/microedition/lcdui/Image.html">Image</A> img, int frameWidth, int frameHeight)</PRE>
<DL>
<DD>Changes the Image containing the Sprite's frames. <p> Replaces the current raw frames of the Sprite with a new set of raw frames. See the constructor <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#Sprite(javax.microedition.lcdui.Image, int, int)"><CODE>Sprite(Image, int, int)</CODE></A> for information on how the frames are created from the image. The values returned by <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getWidth()"><CODE>Layer.getWidth()</CODE></A> and <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getHeight()"><CODE>Layer.getHeight()</CODE></A> will reflect the new frame width and frame height subject to the Sprite's current transform. <p> Changing the image for the Sprite could change the number of raw frames. If the new frame set has as many or more raw frames than the previous frame set, then: <ul> <li>The current frame will be unchanged <li>If a custom frame sequence has been defined (using <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>), it will remain unchanged. If no custom frame sequence is defined (i.e. the default frame sequence is in use), the default frame sequence will be updated to be the default frame sequence for the new frame set. In other words, the new default frame sequence will include all of the frames from the new raw frame set, as if this new image had been used in the constructor. </ul> <p> If the new frame set has fewer frames than the previous frame set, then: <ul> <li>The current frame will be reset to entry 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -