亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲成人综合在线| 中文字幕一区二区日韩精品绯色| 久久香蕉国产线看观看99| 亚洲电影视频在线| 欧美午夜精品久久久久久超碰| 一区视频在线播放| 成人一区二区三区视频在线观看 | 国产成人在线看| 欧美体内she精高潮| 亚洲国产精品尤物yw在线观看| 在线日韩国产精品| 亚洲欧洲美洲综合色网| 91免费国产在线| 亚洲国产wwwccc36天堂| 欧美三片在线视频观看| 丝袜美腿亚洲一区| 日韩一区二区中文字幕| 国产精品亚洲成人| 亚洲色欲色欲www在线观看| 色偷偷一区二区三区| 亚洲国产精品麻豆| 91精品国产丝袜白色高跟鞋| 午夜精品福利在线| 9久草视频在线视频精品| 国产精品美女久久久久高潮| 色综合天天性综合| 一个色在线综合| 精品sm在线观看| 成人免费福利片| 一区二区中文字幕在线| 欧美一区二区在线免费观看| 精品影视av免费| 国产精品麻豆久久久| 欧美久久一二区| 国产一区二区三区高清播放| 亚洲精品一区二区三区蜜桃下载 | 欧美三级电影在线看| 麻豆久久一区二区| 亚洲精品成a人| 久久色成人在线| 欧美精品 日韩| 国产大片一区二区| 99久久国产综合精品麻豆| 日韩—二三区免费观看av| 国产亚洲人成网站| 精品1区2区3区| 国产在线精品不卡| 亚洲成在人线在线播放| 亚洲三级视频在线观看| 日韩欧美一区二区视频| 欧美午夜精品一区二区蜜桃| 成人蜜臀av电影| 国模少妇一区二区三区| 日韩高清在线观看| 亚洲欧美日韩国产综合| 亚洲国产成人自拍| 精品国产亚洲在线| 欧美一卡二卡在线| 精品毛片乱码1区2区3区| 日韩欧美中文一区| 国产夜色精品一区二区av| 久久综合一区二区| 国产精品国产三级国产三级人妇| 国产精品久久久久久久久果冻传媒 | 奇米777欧美一区二区| 日本中文字幕一区二区有限公司| 亚洲一二三四区| 日韩国产精品久久久久久亚洲| 美脚の诱脚舐め脚责91| 黄页网站大全一区二区| 东方欧美亚洲色图在线| 91女神在线视频| 欧美日韩高清一区二区不卡| 日韩欧美国产一区二区三区 | 精品欧美一区二区三区精品久久| 欧美va亚洲va香蕉在线| 久久美女高清视频| 亚洲图片激情小说| 久久国产麻豆精品| 不卡的电影网站| 欧美一区二区三区爱爱| 成人免费一区二区三区在线观看 | 日韩一区二区不卡| 亚洲欧美一区二区视频| 日韩中文字幕一区二区三区| 国产白丝精品91爽爽久久| 欧美妇女性影城| 亚洲视频 欧洲视频| 成人小视频在线| 91精品国产综合久久精品图片| 日韩精品一区二区三区三区免费 | 视频在线观看91| 国产一区二区三区免费看| 91麻豆国产香蕉久久精品| 精品99久久久久久| 午夜久久久久久久久久一区二区| 99视频精品在线| 亚洲国产经典视频| 91蜜桃视频在线| 久久久久亚洲综合| 麻豆精品国产传媒mv男同| 99久久99久久久精品齐齐| 中文字幕不卡的av| 国产高清亚洲一区| 日韩精品一区二区在线观看| 亚洲高清免费视频| 色天天综合色天天久久| 国产精品三级久久久久三级| 粉嫩嫩av羞羞动漫久久久 | 欧美另类videos死尸| 亚洲欧美视频在线观看视频| 成人黄色777网| 国产精品电影一区二区三区| 91浏览器打开| 亚洲v日本v欧美v久久精品| 欧美午夜寂寞影院| 亚洲地区一二三色| 91精品国产一区二区| 精品系列免费在线观看| 久久女同性恋中文字幕| 国产不卡免费视频| 中文字幕亚洲电影| 色综合天天视频在线观看| 日韩国产精品91| 久久天天做天天爱综合色| 国产在线精品一区二区| 精品福利一二区| 成人网在线免费视频| 一区二区三区蜜桃| 精品欧美乱码久久久久久| 色综合久久久久久久| 午夜精品成人在线视频| 久久精品视频在线看| 在线观看欧美精品| 国产乱子伦一区二区三区国色天香| 久久精品一区四区| 日本伦理一区二区| 国产一二精品视频| 亚洲一区二区欧美激情| 欧美激情一区不卡| 欧美日韩成人激情| 国产91富婆露脸刺激对白| 亚洲午夜免费电影| 国产精品女主播在线观看| 欧美日韩你懂得| 丁香婷婷综合五月| 美国av一区二区| 亚洲精品久久久久久国产精华液| 亚洲精品一区二区三区四区高清 | 亚洲激情五月婷婷| 国产欧美综合色| 久久一区二区视频| 欧美系列一区二区| 国产成人综合亚洲91猫咪| 免费在线视频一区| 性欧美疯狂xxxxbbbb| 亚洲天堂2014| 欧美国产视频在线| 日韩欧美一二三区| 制服丝袜国产精品| 欧美日韩一级视频| 色综合天天做天天爱| 国产成人自拍在线| 国产一区二区美女诱惑| 麻豆成人久久精品二区三区红| 久久精品国产亚洲aⅴ| 1区2区3区国产精品| 日韩欧美色综合| 欧美一区二区精品| 日韩欧美不卡在线观看视频| 91精品国产综合久久久久久| 色婷婷亚洲综合| 色悠悠亚洲一区二区| 色婷婷亚洲一区二区三区| 色综合av在线| 欧美日韩一区二区三区高清 | 亚洲一区在线免费观看| 亚洲一区二区五区| 日韩影院在线观看| 日韩电影在线看| 久久精品99国产国产精| 国产精品综合在线视频| 成人毛片视频在线观看| 不卡一区二区在线| 色婷婷亚洲婷婷| 9191成人精品久久| 26uuu精品一区二区三区四区在线| 国产日韩亚洲欧美综合| 一区二区三区四区在线| 日韩va亚洲va欧美va久久| 日韩精彩视频在线观看| 开心九九激情九九欧美日韩精美视频电影| 日韩av成人高清| 国产精品一区二区视频| av在线不卡网| 91精品国产综合久久久久久| 日韩精品一区二区三区中文精品| 精品伦理精品一区| 亚洲国产成人在线| 亚洲成人综合在线|