📄 sprite.html
字号:
Changes the Image containing the Sprite's frames.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setRefPixelPosition(int, int)">setRefPixelPosition</A></B>(int x, int y)</CODE>
<BR>
Sets this Sprite's position such that its reference pixel is located at (x,y) in the painter's coordinate system.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setTransform(int)">setTransform</A></B>(int transform)</CODE>
<BR>
Sets the transform for this Sprite.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.microedition.lcdui.game.Layer"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.microedition.lcdui.game.<A HREF="../../../../javax/microedition/lcdui/game/Layer.html">Layer</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getHeight()">getHeight</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getWidth()">getWidth</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getX()">getX</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getY()">getY</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#isVisible()">isVisible</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#move(int, int)">move</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#setPosition(int, int)">setPosition</A>, <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#setVisible(boolean)">setVisible</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="../../../../java/lang/Object.html">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Field Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="TRANS_NONE"><!-- --></A><H3>
TRANS_NONE</H3>
<PRE>
public static final int <B>TRANS_NONE</B></PRE>
<DL>
<DD>No transform is applied to the Sprite. This constant has a value of <code>0</code>.</DL>
<HR>
<A NAME="TRANS_ROT90"><!-- --></A><H3>
TRANS_ROT90</H3>
<PRE>
public static final int <B>TRANS_ROT90</B></PRE>
<DL>
<DD>Causes the Sprite to appear rotated clockwise by 90 degrees. This constant has a value of <code>5</code>.</DL>
<HR>
<A NAME="TRANS_ROT180"><!-- --></A><H3>
TRANS_ROT180</H3>
<PRE>
public static final int <B>TRANS_ROT180</B></PRE>
<DL>
<DD>Causes the Sprite to appear rotated clockwise by 180 degrees. This constant has a value of <code>3</code>.</DL>
<HR>
<A NAME="TRANS_ROT270"><!-- --></A><H3>
TRANS_ROT270</H3>
<PRE>
public static final int <B>TRANS_ROT270</B></PRE>
<DL>
<DD>Causes the Sprite to appear rotated clockwise by 270 degrees. This constant has a value of <code>6</code>.</DL>
<HR>
<A NAME="TRANS_MIRROR"><!-- --></A><H3>
TRANS_MIRROR</H3>
<PRE>
public static final int <B>TRANS_MIRROR</B></PRE>
<DL>
<DD>Causes the Sprite to appear reflected about its vertical center. This constant has a value of <code>2</code>.</DL>
<HR>
<A NAME="TRANS_MIRROR_ROT90"><!-- --></A><H3>
TRANS_MIRROR_ROT90</H3>
<PRE>
public static final int <B>TRANS_MIRROR_ROT90</B></PRE>
<DL>
<DD>Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 90 degrees. This constant has a value of <code>7</code>.</DL>
<HR>
<A NAME="TRANS_MIRROR_ROT180"><!-- --></A><H3>
TRANS_MIRROR_ROT180</H3>
<PRE>
public static final int <B>TRANS_MIRROR_ROT180</B></PRE>
<DL>
<DD>Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 180 degrees. This constant has a value of <code>1</code>.</DL>
<HR>
<A NAME="TRANS_MIRROR_ROT270"><!-- --></A><H3>
TRANS_MIRROR_ROT270</H3>
<PRE>
public static final int <B>TRANS_MIRROR_ROT270</B></PRE>
<DL>
<DD>Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 270 degrees. This constant has a value of <code>4</code>.</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="Sprite(javax.microedition.lcdui.Image)"><!-- --></A><H3>
Sprite</H3>
<PRE>
public <B>Sprite</B>(<A HREF="../../../../javax/microedition/lcdui/Image.html">Image</A> image)</PRE>
<DL>
<DD>Creates a new non-animated Sprite using the provided Image. This constructor is functionally equivalent to calling <code>new Sprite(image, image.getWidth(), image.getHeight())</code> <p> By default, the Sprite is visible and its upper-left corner is positioned at (0,0) in the painter's coordinate system. <br><DD><DL>
<DT><B>Parameters:</B><DD><CODE>image</CODE> - the <code>Image</code> to use as the single frame for the </code>Sprite<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>img</code> is <code>null</code></DL>
</DD>
</DL>
<HR>
<A NAME="Sprite(javax.microedition.lcdui.Image, int, int)"><!-- --></A><H3>
Sprite</H3>
<PRE>
public <B>Sprite</B>(<A HREF="../../../../javax/microedition/lcdui/Image.html">Image</A> image, int frameWidth, int frameHeight)</PRE>
<DL>
<DD>Creates a new animated Sprite using frames contained in the provided Image. The frames must be equally sized, with the dimensions specified by <code>frameWidth</code> and <code>frameHeight</code>. They may be laid out in the image horizontally, vertically, or as a grid. The width of the source image must be an integer multiple of the frame width, and the height of the source image must be an integer multiple of the frame height. 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 frame width and frame height subject to the Sprite's current transform. <p> Sprites have a default frame sequence corresponding to the raw frame numbers, starting with frame 0. The frame sequence may be modified with <A HREF="../../../../javax/microedition/lcdui/game/Sprite.html#setFrameSequence(int[])"><CODE>setFrameSequence(int[])</CODE></A>. <p> By default, the Sprite is visible and its upper-left corner is positioned at (0,0) in the painter's coordinate system. <p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>image</CODE> - the <code>Image</code> to use for <code>Sprite</code><DD><CODE>frameWidth</CODE> - the <code>width</code>, in pixels, of the individual raw frames<DD><CODE>frameHeight</CODE> - the <code>height</code>, in pixels, of the individual raw frames<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>img</code> is <code>null</code><DD><CODE><A HREF="../../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>frameHeight</code> or <code>frameWidth</code> is less than <code>1</code><DD><CODE><A HREF="../../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the <code>image</code> width is not an integer multiple of the <code>frameWidth</code><DD><CODE><A HREF="../../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the <code>image</code> height is not an integer multiple of the <code>frameHeight</code></DL>
</DD>
</DL>
<HR>
<A NAME="Sprite(javax.microedition.lcdui.game.Sprite)"><!-- --></A><H3>
Sprite</H3>
<PRE>
public <B>Sprite</B>(<A HREF="../../../../javax/microedition/lcdui/game/Sprite.html">Sprite</A> s)</PRE>
<DL>
<DD>Creates a new Sprite from another Sprite. <p> All instance attributes (raw frames, position, frame sequence, current frame, reference point, collision rectangle, transform, and visibility) of the source Sprite are duplicated in the new Sprite.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - the <code>Sprite</code> to create a copy of<DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>s</code> is <code>null</code></DL>
</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="defineReferencePixel(int, int)"><!-- --></A><H3>
defineReferencePixel</H3>
<PRE>
public void <B>defineReferencePixel</B>(int x, int y)</PRE>
<DL>
<DD>Defines the reference pixel for this Sprite. The pixel is defined by its location relative to the upper-left corner of the Sprite's un-transformed frame, and it may lay outside of the frame's bounds. <p> When a transformation is applied, the reference pixel is defined relative to the Sprite's initial upper-left corner before transformation. This corner may no longer appear as the upper-left corner in the painter's coordinate system under current transformation. <p> By default, a Sprite's reference pixel is located at (0,0); that is, the pixel in the upper-left corner of the raw frame. <p> Changing the reference pixel does not change the Sprite's physical position in the painter's coordinate system; that is, the values returned by <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getX()"><CODE>getX()</CODE></A> and <A HREF="../../../../javax/microedition/lcdui/game/Layer.html#getY()"><CODE>getY()</CODE></A> will not change as a result of defining the reference pixel. However, subsequent calls to methods that involve the reference pixel will be impacted by its new definition.<DD><DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -