亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? imageset.java

?? j2me游戲編程光盤源碼
?? JAVA
字號(hào):
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import java.io.IOException;

/**
 * A container for sets of image frames; typically sprites. A single set
 * is made up of one or more states. Each state represents an animation sequence
 * including Image objects for the frames, animation timing and frame
 * dimensions. An example use of this class would be to animate a little dude.
 * If he had two states of existence, standing (which has short breathing
 * animation) and walking (which has a much longer animation). This would be
 * implemented by creating an ImageSet object and then adding two states, each
 * with their own Image array for all the animation frames (use the static
 * methods at the end of this class to load a clipped file image and then
 * extract the image frame array from it). You can then use a Sprite class
 * associated with this ImageSet to draw the character to the screen as well as
 * keep track of animation frames.
 * @author Martin J. Wells
 */
public class ImageSet
{
   private int totalStates;		// incremented by addState method only
   private Image[][] stateFrames;
   private int[] stateAnimTime, stateFrameWidth, stateFrameHeight;

   /**
    * Constructor for a new image. You will need to call addState to add the
    * various states (and their associated images and animation data) before
    * the object is really usable.
    * @param numStates The initial number of states (since ImageSet uses an
    * array internally (for speed) it costs a lot to expand the internal size
    * beyond this number -- typically you'll know the exact number of states
    * beforehand anyway. If not, the addState code will expand the array when
    * required.
    */
   public ImageSet(int numStates)
   {
      stateAnimTime = new int[numStates];
      stateFrameWidth = new int[numStates];
      stateFrameHeight = new int[numStates];
      stateFrames = new Image[numStates][];
   }

   /**
    * Adds a new state to the ImageSet including an array of images and the
    * number of milliseconds to animate the entire state (NOT each frame). If
    * this is not an animating set then just use 0 for the animtime. To animate
    * you will need to create a Sprite object linked to this ImageSet.
    * @param frames An array of javax.microedition.lcdui.Image objects.
    * @param animTime The number of milliseconds delay to animate ALL frames.
    */
   public final void addState(Image frames[], int animTime)
   {
      int state = totalStates++;

      if (state >= stateFrames.length)
      {
         // expand the number of states
         stateAnimTime = Tools.expandArray(stateAnimTime, 1);
         stateFrameWidth = Tools.expandArray(stateFrameWidth, 1);
         stateFrameHeight = Tools.expandArray(stateFrameHeight, 1);
         stateFrames = Tools.expandArray(stateFrames, 1);
      }

      stateAnimTime[state] = animTime;
      stateFrameWidth[state] = frames[0].getWidth();
      stateFrameHeight[state] = frames[0].getHeight();
      stateFrames[state] = frames;
   }

   /**
    * Gets the number of frames for a particular state in the ImageSet.
    * @param state The state you want to know about.
    * @return The number of frames in that state.
    */
   public final int getTotalFrames(int state)
   {
      return stateFrames[state].length;
   }

   /**
    * Gets the total amount time to animate all the frames of a given state.
    * Note this is not the delay per frame.
    * @param state The state you want to know about.
    * @return The animation delay (in milliseconds) corresponding to the given
    * state.
    */
   public final int getAnimTime(int state)
   {
      return stateAnimTime[state];
   }

   /**
    * Gets the amount of time to spend on each frame of a set to animate it.
    * This is just a convenience method that returns the animation time for
    * a state divided by the total number of frames.
    * @param state The state you want to know about.
    * @return The number of milliseconds delay for each frame of a given state.
    */
   public final int getAnimTimePerFrame(int state)
   {
      return stateAnimTime[state] / stateFrames[state].length;
   }

   /**
    * Draws a specific frame of this sprite onto a graphics context.
    * @param target The target graphics context to draw on.
    * @param state The state corresponding to the frame being drawn.
    * @param frame The number of the frame you want to draw.
    * @param targetX The x-position to draw the frame.
    * @param targetY The y-position to draw the frame.
    */
   public final void draw(Graphics target, int state, int frame, int targetX, int targetY)
   {
      if (stateFrames[state][frame] != null)
         target.drawImage(stateFrames[state][frame],
                          targetX, targetY, Tools.GRAPHICS_TOP_LEFT);
   }

   /**
    * Extract an Image corresponding to a particular state and frame.
    * @param state The state you're after.
    * @param frame The frame you're after.
    * @return The image corresponding to the given frame in the given state.
    */
   public final Image getFrame(int state, int frame)
   {
      return stateFrames[state][frame];
   }

   //
   // STATIC IMAGE TOOLS
   //

   /**
    * Static utility method to loap up a portion of an image from a file. Note
    * that the file must be in your JAR (or otherwise accessible) by the MID in
    * order to be loaded.
    * @param filename The name of the resource file to load.
    * @param originX The starting x position of the file image you want to load.
    * @param originY The starting y position of the file image you want to load.
    * @param width The width of the image you want to clip to.
    * @param height The height of the image you want to clip to.
    * @return A new Image object containing only the rectangle of originX,
    * originY, width and depth.
    */
   public final static Image loadClippedImage(String filename, int originX, int originY, int width,
                                              int height)
   {
      try
      {
         // load full image from file and create a mutable version
         Image fileImage = Image.createImage(filename);
         // use the getImageRegion method to extract out only the bit we want.
         return getImageRegion(fileImage, originX, originY, width, height);
      }

      catch (IOException ioe)
      {
         System.out.println("can't load file: " + filename);
         return null;
      }
   }

   /**
    * Static utility method to loap up a portion of an image from a file. Note
    * that the file must be in your JAR (or otherwise accessible) by the MID in
    * order to be loaded. The width and height of the portion is assumed to be
    * the size of the file image.
    * @param filename The name of the resource file to load.
    * @param originX The starting x position of the file image you want to load.
    * @param originY The starting y position of the file image you want to load.
    * @return A new Image object containing only the rectangle starting at
    * originX, originY.
    */
   public final static Image loadClippedImage(String filename, int originX, int originY)
   {
      try
      {
         // load full image from file and create a mutable version
         Image fileImage = Image.createImage(filename);

         // shortcut out of here so we can avoid creating another image if they
         // are just using this method to load an image normally (no clipping).
         if (originX == 0 && originY == 0) return fileImage;

         // use the getImageRegion method to extract out only the bit we want.
         return getImageRegion(fileImage, originX, originY, fileImage.getWidth(), fileImage.getHeight());
      }

      catch (IOException ioe)
      {
         System.out.println("can't load file: " + filename);
         return null;
      }
   }

   /**
    * Extracts a portion of an image using clipping.
    * @param source The source image.
    * @param x The starting x position of the clipping rectangle.
    * @param y The starting y position of the clipping rectangle.
    * @param width The width of the clipping rectangle.
    * @param height The height of the clipping rectangle.
    * @return A new Image object containing only the portion of the image
    * withing the x, y, width, height rectangle.
    */
   public final static Image getImageRegion(Image source, int x, int y, int width, int height)
   {
      // create a placeholder for our resulting image region
      Image result = Image.createImage(width, height);

      if (x + width > source.getWidth() || y + height > source.getHeight())
         System.out.println("Warning: attempting extract using (" +
                            x + "," + y + "," + width + "," + height + ") when image is " +
                            "(" + source.getWidth() + "," + source.getHeight() + ")");

      // draw the image, offset by the region starting position
      result.getGraphics().drawImage(source, -x, -y, Tools.GRAPHICS_TOP_LEFT);

      return result;
   }

   /**
    * Gets an array of images by breaking a larger image into smaller frames.
    * @param sourceImage The image to extract the frames from.
    * @param sourceX The starting x position in the source image to use.
    * @param sourceY The starting y position in the source image to use.
    * @param framesWide The number of frames across the source image to extract.
    * @param framesHigh The number of frames down the source image to extract.
    * @param frameWidth The width of each of those frames.
    * @param frameHeight The height of each of those frames.
    * @return An array containing an image for each frame.
    */
   public final static Image[] extractFrames(Image sourceImage, int sourceX,
                                             int sourceY,
                                             int framesWide, int framesHigh,
                                             int frameWidth, int frameHeight)
   {
      // extract all the frames from the source image
      Image[] frames = new Image[framesWide * framesHigh];
      int frameCount = 0;

      for (int fy = 0; fy < framesHigh; fy++)
         for (int fx = 0; fx < framesWide; fx++)
            frames[frameCount++] =
                    getImageRegion(sourceImage, sourceX + (fx * frameWidth),
                                   sourceY + (fy * frameHeight),
                                   frameWidth, frameHeight);
      return frames;
   }


}











?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精选在线视频| 中文字幕一区二区三区色视频| 不卡的av网站| 激情亚洲综合在线| 久久99久久精品欧美| 日韩国产成人精品| 青娱乐精品视频| 精品亚洲成av人在线观看| 麻豆成人91精品二区三区| 老司机精品视频线观看86| 国产综合色精品一区二区三区| 精品一区二区三区免费毛片爱| 久久激情五月激情| 国产+成+人+亚洲欧洲自线| 成人av第一页| 欧美日韩国产高清一区二区| 91精品国产综合久久福利软件 | 狠狠色狠狠色综合系列| 久久99蜜桃精品| 国产福利91精品一区二区三区| av高清久久久| 欧美日韩精品一区二区天天拍小说 | 成人免费视频视频在线观看免费 | 欧美日韩午夜在线| 在线不卡免费av| 欧美精品一区在线观看| 中文字幕日韩欧美一区二区三区| 中文字幕av资源一区| 亚洲曰韩产成在线| 久久精品国产99国产精品| 波多野结衣一区二区三区| 欧美色倩网站大全免费| 26uuu国产在线精品一区二区| 一区视频在线播放| 男男视频亚洲欧美| 色综合天天性综合| 欧美一区二区高清| 亚洲欧洲精品天堂一级 | 久久久久久久精| 一区二区在线免费观看| 精品影视av免费| 日本高清无吗v一区| 久久久久久久综合狠狠综合| 亚洲综合色成人| 国产成人av电影在线| 欧美综合色免费| 久久麻豆一区二区| 五月天亚洲婷婷| 99久久婷婷国产| 欧美精品一区二区三区四区| 午夜视频在线观看一区二区| eeuss国产一区二区三区| 精品国产伦理网| 日韩高清一区二区| 色av成人天堂桃色av| 国产日韩一级二级三级| 麻豆精品一区二区| 色婷婷国产精品| 国产精品免费av| 国产米奇在线777精品观看| 欧美天天综合网| 亚洲精品免费电影| 大美女一区二区三区| 精品国产乱码久久久久久蜜臀| 天堂在线一区二区| 欧美日韩一区二区三区不卡| 一区二区三区国产精华| 91在线国产福利| 国产精品白丝在线| 成人av在线网站| 国产精品久久久久影院| voyeur盗摄精品| 亚洲欧洲无码一区二区三区| 成人av综合一区| 一区在线中文字幕| 日本黄色一区二区| 亚洲v中文字幕| 欧美老年两性高潮| 日本三级亚洲精品| 欧美成人a∨高清免费观看| 久久99热国产| 亚洲国产精品传媒在线观看| a在线欧美一区| 伊人婷婷欧美激情| 欧美老女人第四色| 久久99九九99精品| 国产精品欧美综合在线| 成人av综合在线| 亚洲福利视频三区| 91精品国产91久久久久久一区二区| 天堂av在线一区| 亚洲精品一区二区三区精华液| 国产一区二区三区最好精华液| 日韩精品一区国产麻豆| 国产精品白丝jk白祙喷水网站| 中文久久乱码一区二区| 日本久久一区二区| 日韩一区精品视频| 中文字幕国产一区二区| 在线国产电影不卡| 久久激五月天综合精品| 国产日产欧产精品推荐色| 91在线观看下载| 日韩成人精品在线观看| 中文字幕免费不卡| 欧美三日本三级三级在线播放| 九九视频精品免费| 亚洲男同性恋视频| 久久无码av三级| 欧美这里有精品| 国产一区二区免费视频| 一区二区三区久久| 国产三级欧美三级| 欧美日韩国产影片| 成人一区二区三区中文字幕| 亚洲国产精品精华液网站| 亚洲国产高清不卡| 日韩欧美精品在线视频| 91麻豆免费看| 国产美女精品一区二区三区| 亚洲成人免费在线| 亚洲特黄一级片| 久久久久亚洲综合| 日韩欧美国产麻豆| 欧美日韩中字一区| 成人h动漫精品一区二区| 麻豆精品一区二区综合av| 一个色妞综合视频在线观看| 精品日本一线二线三线不卡| 欧美午夜精品久久久| 成人av午夜影院| 国内一区二区在线| 日本不卡在线视频| 亚洲国产成人av好男人在线观看| 中文字幕一区三区| 国产亚洲成av人在线观看导航| 日韩一二三区不卡| 欧美日韩国产首页| 欧美影院一区二区三区| 91色.com| 97国产一区二区| 99精品欧美一区| 波多野结衣中文一区| 成人午夜精品在线| 成人免费视频免费观看| 国产成人精品网址| 成人免费毛片app| 不卡一区二区在线| 成a人片国产精品| a4yy欧美一区二区三区| 97久久精品人人做人人爽| 99re6这里只有精品视频在线观看| 成人高清视频在线观看| 99久久夜色精品国产网站| 成人午夜大片免费观看| 白白色亚洲国产精品| 99精品欧美一区二区三区综合在线| 成人黄色av网站在线| 不卡的电影网站| 在线观看网站黄不卡| 欧美日韩国产高清一区二区三区 | 福利一区二区在线观看| 一级日本不卡的影视| 亚洲男女毛片无遮挡| 亚洲国产cao| 午夜精品123| 毛片av一区二区| 风间由美一区二区av101| 97精品国产97久久久久久久久久久久| 成人国产精品免费观看动漫| 99久久综合99久久综合网站| 在线免费精品视频| 337p亚洲精品色噜噜| 2023国产精华国产精品| 国产精品电影一区二区| 一区二区成人在线| 激情深爱一区二区| 91在线视频免费91| 69p69国产精品| 国产日韩av一区| 亚洲一线二线三线视频| 免费观看久久久4p| 99精品黄色片免费大全| 精品视频免费在线| 久久久精品影视| 亚洲成人高清在线| 国产成人鲁色资源国产91色综| 色综合久久九月婷婷色综合| 日韩西西人体444www| 国产精品久久网站| 麻豆国产精品视频| 欧美亚洲综合在线| 久久久久高清精品| 亚洲成人免费视频| 99久久99精品久久久久久| 欧美一区二区人人喊爽| 亚洲精品国产a久久久久久| 国产在线国偷精品免费看| 成人网男人的天堂| 久久免费视频一区|