• 大小: 550KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Java
  • 标签: java  

资源简介

一个用java实现的简单地图编辑器,里面的贴图可以自由更换

资源截图

代码片段和文件信息

import java.awt.Image;
import java.util.ArrayList;

/**
    The Animation class manages a series of images (frames) and
    the amount of time to display each frame.
*/
public class Animation {

    private ArrayListame> frames;
    private int currframeIndex;
    private long animTime;
    private long totalDuration;


    /**
        Creates a new empty Animation.
    */
    public Animation() {
        frames = new ArrayListame>();
        totalDuration = 0;
        start();
    }


    /**
        Adds an image to the animation with the specified
        duration (time to display the image).
    */
    public synchronized void addframe(Image image
        long duration)
    {
        totalDuration += duration;
        frames.add(new Animframe(image totalDuration));
    }


    /**
        Starts this animation over from the beginning.
    */
    public synchronized void start() {
        animTime = 0;
        currframeIndex = 0;
    }


    /**
        Updates this animation‘s current image (frame) if
        necessary.
    */
    public synchronized void update(long elapsedTime) {
        if (frames.size() > 1) {
            animTime += elapsedTime;

            if (animTime >= totalDuration) {
                animTime = animTime % totalDuration;
                currframeIndex = 0;
            }

            while (animTime > getframe(currframeIndex).endTime) {
                currframeIndex++;
            }
        }
    }

    /**
        Gets this Animation‘s current image. Returns null if this
        animation has no images.
    */
    public synchronized Image getImage() {
        if (frames.size() == 0) {
            return null;
        }
        else {
            return getframe(currframeIndex).image;
        }
    }


    private Animframe getframe(int i) {
        return (Animframe)frames.get(i);
    }


    private class Animframe {

        Image image;
        long endTime;

        public Animframe(Image image long endTime) {
            this.image = image;
            this.endTime = endTime;
        }
    }
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        301  2011-12-11 20:27  MapEditor\.classpath

     文件        385  2011-12-11 20:27  MapEditor\.project

     文件        629  2011-12-11 20:27  MapEditor\.settings\org.eclipse.jdt.core.prefs

     文件        529  2011-12-23 19:32  MapEditor\bin\Animation$Animframe.class

     文件       1567  2011-12-23 19:32  MapEditor\bin\Animation.class

     文件       5396  2011-12-22 21:32  MapEditor\bin\Createframe.class

     文件       1652  2011-12-19 21:41  MapEditor\bin\GameAction.class

     文件       8017  2011-12-23 19:34  MapEditor\bin\InputManager.class

     文件       8186  2011-12-23 20:22  MapEditor\bin\MapEditor.class

     文件       7898  2011-12-23 20:12  MapEditor\bin\MapEditorframe.class

     文件        560  2011-12-23 19:34  MapEditor\bin\Sprite$Route.class

     文件       3592  2011-12-23 19:34  MapEditor\bin\Sprite.class

     文件        505  2011-12-20 22:37  MapEditor\bin\TileAttribute.class

     文件       3751  2011-12-23 19:35  MapEditor\bin\TileMap.class

     文件      34443  2009-12-15 09:22  MapEditor\images\fight000_1-1.JPG

     文件        777  2011-08-01 08:57  MapEditor\images\godown\103_40.png

     文件        757  2011-08-01 08:57  MapEditor\images\godown\103_41.png

     文件        749  2011-08-01 08:57  MapEditor\images\godown\103_42.png

     文件        777  2011-08-01 08:57  MapEditor\images\godown\103_43.png

     文件        752  2011-08-01 08:57  MapEditor\images\godown\103_44.png

     文件        742  2011-08-01 08:57  MapEditor\images\godown\103_45.png

     文件        740  2011-08-01 08:57  MapEditor\images\godown\103_46.png

     文件        763  2011-08-01 08:57  MapEditor\images\godown\103_47.png

     文件        807  2011-08-01 08:57  MapEditor\images\goleft\103_56.png

     文件        769  2011-08-01 08:57  MapEditor\images\goleft\103_57.png

     文件        768  2011-08-01 08:57  MapEditor\images\goleft\103_58.png

     文件        780  2011-08-01 08:57  MapEditor\images\goleft\103_59.png

     文件        782  2011-08-01 08:57  MapEditor\images\goleft\103_60.png

     文件        821  2011-08-01 08:57  MapEditor\images\goleft\103_61.png

     文件        784  2011-08-01 08:57  MapEditor\images\goleft\103_62.png

............此处省略66个文件信息

评论

共有 条评论