Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.devox.amori.controls;
- import java.awt.Graphics2D;
- import java.awt.image.BufferedImage;
- public class Animation
- {
- private BufferedImage buff;
- private int x, y, frames;
- private BufferedImage[] images;
- private int curFrame;
- private int counter=0;
- public Animation(int frames, BufferedImage[] bi, int interval, int x, int y){
- this.x = x;
- this.y = y;
- this.frames = frames;
- this.images = bi;
- }
- public void Update(){
- frames++;
- }
- public void Draw(Graphics2D g2d){
- g2d.drawImage(images[curFrame], x, y, null);
- }
- public void LoopAnim(int speed){
- if(counter == speed){
- curFrame++;
- if(curFrame>frames){
- curFrame=0;
- }
- }
- counter++;
- if(counter==speed){
- counter=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment