/** * 转化一组Image为动画图像 * * @param images * @param maxFrame * @param row * @param col * @param timer * @return */ public static Animation getDefaultAnimation(LTexture[] images, int maxFrame, int timer) { Animation animation = new Animation(); if (maxFrame != -1) { for (int i = 0; i < maxFrame; i++) { animation.addFrame(images[i], timer); } } else { for (int i = 0; i < images.length; i++) { animation.addFrame(images[i], timer); } } return animation; }
public Bitmap getBitmap() { SpriteImage simg = animation.getSpriteImage(); if (simg != null) { return simg.getBitmap(); } return null; }
public void dispose() { if (gifDecoder != null) { gifDecoder = null; } if (animation != null) { animation.dispose(); animation = null; } }
public GIFAnimation(String fileName) { this.gifDecoder = new GIFDecoder(); this.gifDecoder.read(fileName); RectBox d = gifDecoder.getFrameSize(); this.width = (int) d.getWidth(); this.height = (int) d.getHeight(); this.isVisible = true; this.animation = new Animation(); int delay; for (int i = 0; i < gifDecoder.getFrameCount(); i++) { delay = gifDecoder.getDelay(i); animation.addFrame(gifDecoder.getFrame(i), delay == 0 ? 100 : delay); } }
/** * 转化指定文件为动画图像 * * @param fileName * @param maxFrame * @param row * @param col * @param timer * @return */ public static Animation getDefaultAnimation( String fileName, int maxFrame, int row, int col, int timer) { return Animation.getDefaultAnimation( TextureUtils.getSplitTextures(fileName, row, col), maxFrame, timer); }
public void createUI(LGraphics g) { if (isVisible) { g.drawImage(animation.getSpriteImage().getImage(), x(), y()); } }
public void update(long elapsedTime) { if (isVisible) { animation.update(elapsedTime); } }
public boolean isRunning() { return animation.isRunning(); }
public void setRunning(boolean runing) { animation.setRunning(runing); }
public float getAlpha() { return animation.getAlpha(); }