Add original project.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.hyperling.apps.games;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/22/16.
|
||||
*/
|
||||
|
||||
public class Animation {
|
||||
|
||||
private Bitmap[] frames;
|
||||
private int currentFrame;
|
||||
private long startTime;
|
||||
private long delay;
|
||||
private boolean playedOnce;
|
||||
|
||||
public void setFrames(Bitmap[] f) {
|
||||
frames = f;
|
||||
}
|
||||
|
||||
public void setDelay(long d) {
|
||||
delay = d;
|
||||
}
|
||||
|
||||
public void setCurrentFrame(int cf) {
|
||||
currentFrame = cf;
|
||||
}
|
||||
|
||||
public Bitmap getImage(){
|
||||
return frames[currentFrame];
|
||||
}
|
||||
|
||||
public int getCurrentFrame(){
|
||||
return currentFrame;
|
||||
}
|
||||
|
||||
public boolean getPlayedOnce(){
|
||||
return playedOnce;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
long elapsed = System.currentTimeMillis() - startTime;
|
||||
if (elapsed > delay){
|
||||
currentFrame++;
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (currentFrame == frames.length){
|
||||
currentFrame = 0;
|
||||
playedOnce = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user