亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲国产高清在线| 午夜视频久久久久久| 日本免费新一区视频| 欧美区一区二区三区| 天天爽夜夜爽夜夜爽精品视频| 欧美日本高清视频在线观看| 日韩极品在线观看| 精品免费国产二区三区| 国产精品一区二区无线| 亚洲欧洲精品一区二区三区| 在线观看亚洲精品| 日本欧美一区二区| 精品少妇一区二区三区免费观看| 国产精品中文欧美| 国产精品国产三级国产aⅴ中文| www.视频一区| 亚洲午夜精品17c| 日韩欧美在线观看一区二区三区| 国产伦精品一区二区三区视频青涩 | 91丨porny丨最新| 亚洲一区在线视频| jvid福利写真一区二区三区| 欧美一级片免费看| 久久精品一区二区三区不卡 | 亚洲一区在线视频观看| 亚洲国产视频在线| 美女一区二区三区| 岛国精品一区二区| 亚洲精品va在线观看| 日韩专区中文字幕一区二区| 久久午夜国产精品| 在线视频国产一区| 国产一区二区调教| 亚洲午夜影视影院在线观看| 国产偷国产偷精品高清尤物| 国产精品1区2区3区在线观看| 亚洲精品欧美激情| 久久奇米777| 欧美午夜精品免费| 国产·精品毛片| 日韩av在线免费观看不卡| 国产精品乱码一区二三区小蝌蚪| 欧美精品粉嫩高潮一区二区| 成人综合日日夜夜| 精品一区二区三区久久久| 一区二区三区国产精品| 精品国产成人系列| 欧美三级资源在线| 成人免费毛片app| 久久se精品一区精品二区| 一区二区三区免费看视频| 久久久美女毛片| 在线综合亚洲欧美在线视频| www.亚洲色图.com| 国产一区二区不卡老阿姨| 首页综合国产亚洲丝袜| 亚洲欧美偷拍卡通变态| 久久久精品国产99久久精品芒果| 欧美吞精做爰啪啪高潮| 免费成人美女在线观看| 亚洲国产中文字幕在线视频综合| 欧美国产一区视频在线观看| 久久青草国产手机看片福利盒子| 欧美日韩在线免费视频| 国产精品一二三四区| 亚洲另类在线制服丝袜| 欧美日韩国产片| 青青草国产精品97视觉盛宴| 久久久久久久久久久久久女国产乱 | 亚洲视频香蕉人妖| 91黄色激情网站| 久久久久久久久久久99999| 欧美日韩一区二区三区在线| 欧美在线色视频| 欧美性猛片xxxx免费看久爱| 色噜噜夜夜夜综合网| 一本久道久久综合中文字幕 | 亚洲一区二区三区美女| 中文字幕一区二区三区在线观看| 精品理论电影在线| 26uuu亚洲综合色欧美| 精品国产凹凸成av人导航| 26uuu亚洲综合色| 国产日本欧美一区二区| 国产欧美日韩在线观看| 国产精品情趣视频| 亚洲欧洲精品成人久久奇米网| 国产精品视频九色porn| 国产精品福利一区二区| 亚洲精品自拍动漫在线| 午夜伊人狠狠久久| 日本aⅴ免费视频一区二区三区| 蜜臀精品久久久久久蜜臀| 久久99精品久久久久久| 久久99日本精品| 国产iv一区二区三区| 91免费版在线| 欧美男人的天堂一二区| www激情久久| 亚洲欧美偷拍三级| 天天综合天天综合色| 久久成人av少妇免费| 成人av午夜电影| 在线观看国产一区二区| 日韩欧美一区中文| 亚洲欧洲www| 日韩主播视频在线| 福利一区二区在线| 欧美色综合久久| 久久久久久久久久久电影| 亚洲精品国产a久久久久久| 蜜臀av一级做a爰片久久| 成人app在线| 欧美群妇大交群的观看方式| 久久久精品中文字幕麻豆发布| 亚洲精品一二三| 久久精品久久99精品久久| av一区二区三区在线| 欧美精选一区二区| 国产精品每日更新| 日本欧美大码aⅴ在线播放| av亚洲精华国产精华| 日韩一区二区三区在线观看| 亚洲欧洲在线观看av| 精品一区二区三区在线观看| 91成人免费在线| 国产日韩视频一区二区三区| 亚洲福利视频一区| 国产白丝精品91爽爽久久| 91精品在线免费观看| 中文字幕在线不卡一区| 久久精品国产99久久6| 欧美亚洲国产一区在线观看网站 | 日韩美女精品在线| 极品少妇一区二区三区精品视频| 欧美亚洲国产一区二区三区va| 久久久久久久国产精品影院| 天堂av在线一区| 91视频精品在这里| 中文字幕成人av| 国产精品99久久久| 精品欧美一区二区久久| 舔着乳尖日韩一区| 欧美色视频一区| 一区二区三区高清| 9l国产精品久久久久麻豆| 久久久精品中文字幕麻豆发布| 日本欧美大码aⅴ在线播放| 欧美日韩精品是欧美日韩精品| 亚洲欧洲综合另类在线| caoporen国产精品视频| 久久久国产精品麻豆| 精品一区二区三区免费观看| 日韩一区二区在线看| 亚洲mv大片欧洲mv大片精品| 欧美性视频一区二区三区| 亚洲免费在线观看视频| 99久久综合99久久综合网站| 国产精品久久久久久久久免费桃花| 国产乱码精品一区二区三| 精品美女在线播放| 激情丁香综合五月| 欧美成人艳星乳罩| 国内精品伊人久久久久影院对白| 91精品国产综合久久国产大片| 亚洲bt欧美bt精品777| 欧美人与性动xxxx| 免费av网站大全久久| 日韩欧美一二区| 久久精品国产成人一区二区三区 | 精品久久一区二区三区| 九九国产精品视频| 久久精子c满五个校花| 国精品**一区二区三区在线蜜桃| www日韩大片| 国产成人av网站| 中文字幕一区二区三区四区不卡| 99re成人精品视频| 夜夜揉揉日日人人青青一国产精品| 欧洲国内综合视频| 久久精品国产在热久久| 国产午夜三级一区二区三| 波多野结衣在线一区| 亚洲综合视频网| 日韩精品一区二区三区中文不卡| 国产老妇另类xxxxx| 综合久久给合久久狠狠狠97色| 欧美专区日韩专区| 久久99久久99| 亚洲欧洲av色图| 欧美美女视频在线观看| 国产剧情一区二区| 亚洲黄色av一区| 日韩视频不卡中文| 99久久综合狠狠综合久久| 亚洲大片在线观看| 久久久777精品电影网影网 | 中文字幕欧美一区| 欧美人妇做爰xxxⅹ性高电影| 国精产品一区一区三区mba视频|