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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? imageset.java

?? j2me游戲編程光盤源碼
?? JAVA
字號:
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;
   }


}











?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
六月丁香综合在线视频| 亚洲乱码国产乱码精品精可以看 | 9191成人精品久久| 91香蕉视频污在线| 色婷婷av一区二区三区大白胸 | 亚洲日本va午夜在线影院| 亚洲人成网站影音先锋播放| 亚洲国产日韩a在线播放性色| 天天影视网天天综合色在线播放| 美日韩黄色大片| 成人国产在线观看| 欧美美女直播网站| 国产三级久久久| 日本午夜一本久久久综合| 国产成人精品免费在线| 在线视频亚洲一区| 欧美国产一区二区| 六月丁香婷婷久久| 欧美亚洲国产怡红院影院| 国产色综合一区| 日日夜夜免费精品| 色狠狠av一区二区三区| 久久夜色精品国产噜噜av| 欧美a级理论片| 91国偷自产一区二区开放时间 | 久久久久国产精品麻豆| 亚洲电影你懂得| 色婷婷一区二区三区四区| 成人高清视频免费观看| 日韩一级视频免费观看在线| 艳妇臀荡乳欲伦亚洲一区| 成人动漫在线一区| 国产精品视频在线看| 麻豆传媒一区二区三区| 91精品国产91热久久久做人人| 亚洲自拍另类综合| 成人精品免费看| 成人小视频在线| 久久色成人在线| 成人午夜激情片| 国产精品午夜在线观看| 成人午夜在线播放| 亚洲女同ⅹxx女同tv| 欧美日韩精品一区二区在线播放 | 国内久久婷婷综合| 久久久午夜电影| 色欧美日韩亚洲| 天天色天天爱天天射综合| 日韩一级大片在线观看| 国产成人av电影在线播放| 国产精品日日摸夜夜摸av| 欧美专区亚洲专区| 久草精品在线观看| 国产精品久久久久婷婷二区次| 欧美偷拍一区二区| 图片区小说区国产精品视频| 久久综合九色综合欧美就去吻| 国产成人啪免费观看软件| 亚洲一级二级三级在线免费观看| 欧美一区在线视频| 91精品福利视频| 国产精品99久久不卡二区| 一区二区免费看| 这里是久久伊人| 精品在线免费视频| 亚洲欧美色图小说| 亚洲国产高清不卡| 91精品国产综合久久久久久久久久 | 日韩极品在线观看| 亚洲视频中文字幕| 日韩欧美色综合网站| va亚洲va日韩不卡在线观看| 亚洲成人综合在线| 亚洲日本韩国一区| 亚洲欧美日韩在线不卡| 中文字幕av一区 二区| 精品国产凹凸成av人导航| 91在线视频免费观看| 国产一区高清在线| 久久精品国产99国产精品| 日韩**一区毛片| 蜜臀av性久久久久蜜臀av麻豆| 麻豆国产精品一区二区三区| 欧美一级日韩一级| 国产激情精品久久久第一区二区| 亚洲成人在线观看视频| 亚洲成人av中文| 欧美aaaaa成人免费观看视频| 精品一区二区三区免费播放 | 国产一区二区在线免费观看| 人禽交欧美网站| 国产精品一级在线| 国产在线视频不卡二| 久久99精品一区二区三区三区| 九九九精品视频| 99视频热这里只有精品免费| 成年人国产精品| 欧美中文字幕一二三区视频| 极品少妇一区二区三区精品视频 | 国产喂奶挤奶一区二区三区| 国产精品高潮呻吟久久| 亚洲色图都市小说| 亚洲国产婷婷综合在线精品| 免费精品99久久国产综合精品| 天天影视涩香欲综合网| 国产一区二区三区电影在线观看| 粉嫩av亚洲一区二区图片| 在线观看国产91| 精品美女一区二区| 婷婷成人激情在线网| 欧美日韩国产乱码电影| 亚洲va韩国va欧美va| 欧美日本免费一区二区三区| 亚洲视频在线观看一区| 成人一级片在线观看| 欧美成人免费网站| 天天影视涩香欲综合网| 91搞黄在线观看| 亚洲人精品一区| 欧美性生交片4| 亚洲永久免费视频| 日韩一二三四区| 国产综合色精品一区二区三区| 欧美电视剧在线观看完整版| 国产成人久久精品77777最新版本| 精品处破学生在线二十三| 免费成人性网站| 日韩精品在线一区| 丝袜诱惑制服诱惑色一区在线观看 | 在线中文字幕一区二区| 亚洲嫩草精品久久| 欧美午夜精品一区二区三区| 亚洲成人一区在线| 久久久综合激的五月天| 成人永久看片免费视频天堂| 亚洲欧美日韩精品久久久久| 欧美三级日韩在线| 石原莉奈在线亚洲三区| 欧美成人video| 99精品视频中文字幕| 青娱乐精品在线视频| www激情久久| 91毛片在线观看| 国产成人免费在线| 日日骚欧美日韩| 夜夜爽夜夜爽精品视频| 久久蜜臀精品av| 69久久夜色精品国产69蝌蚪网| 国产一区二区三区久久久| 亚洲一区免费在线观看| 国产嫩草影院久久久久| www一区二区| 成人av免费在线观看| 丁香一区二区三区| 蜜臀久久99精品久久久画质超高清 | 国产乱淫av一区二区三区| 亚洲欧美国产高清| 久久精品一区二区三区不卡| 欧美一级欧美一级在线播放| 欧美中文字幕一区| 91亚洲午夜精品久久久久久| 免费观看在线色综合| 午夜久久久久久| 伊人性伊人情综合网| 亚洲欧洲中文日韩久久av乱码| 欧美激情一区二区三区四区| 国产精品久久一级| 综合网在线视频| 亚洲一区二区三区在线看| 一区二区三区精品视频| 亚洲夂夂婷婷色拍ww47| 国产精品丝袜一区| 亚洲欧美自拍偷拍色图| 亚洲免费资源在线播放| 亚洲在线中文字幕| 午夜久久福利影院| 国产一区二区三区四区五区入口| 久久99热这里只有精品| 春色校园综合激情亚洲| 99re热视频这里只精品 | 久久亚洲私人国产精品va媚药| 国产亚洲欧美中文| 一区二区三区免费在线观看| 国产精品一区二区在线观看网站 | 免费久久99精品国产| 看国产成人h片视频| 国产精品一区二区久久精品爱涩| 色中色一区二区| 制服丝袜日韩国产| 国产农村妇女精品| 视频一区二区三区在线| 国内精品视频666| 色八戒一区二区三区| 欧美va亚洲va香蕉在线| 亚洲激情第一区| 国产成人综合网| 久久―日本道色综合久久| 一级中文字幕一区二区| 成人中文字幕电影| 精品国产免费一区二区三区四区|