1 package erland.game.tileadventure;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class Animation implements AnimationInterface, Cloneable {
23 private int[] imageList;
24 private int current;
25 private int speed;
26 private int animationCounter;
27 public Animation(int speed, int[] imageList) {
28 this.speed= speed;
29 this.imageList = imageList;
30 this.current = 0;
31 this.animationCounter = 0;
32 }
33 public int getNextImage() {
34 animationCounter++;
35 if(speed>0 && animationCounter>=speed) {
36 animationCounter=0;
37 current++;
38 if(current>=imageList.length) {
39 current = 0;
40 }
41 }
42 return imageList[current];
43 }
44
45 public Object clone() {
46 Animation a = null;
47 try {
48 a = (Animation) super.clone();
49 } catch (CloneNotSupportedException e) {
50 e.printStackTrace();
51 }
52 return a;
53 }
54 }