61 lines
2.1 KiB
Java
61 lines
2.1 KiB
Java
package com.jalenwinslow.game.sprite;
|
|
|
|
import com.badlogic.gdx.graphics.Texture;
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
import com.jalenwinslow.game.Handler;
|
|
import com.jalenwinslow.game.gameobjects.GameObject;
|
|
|
|
/**
|
|
* Created by jalen on 2/18/2018.
|
|
*/
|
|
|
|
public abstract class Sprite {
|
|
|
|
protected Handler handler;
|
|
protected Rectangle bounds;
|
|
protected boolean manual;
|
|
protected GameObject gameObj;
|
|
|
|
protected TextureRegion texture;
|
|
protected TextureRegion[] frames;
|
|
protected TextureRegion currentFrame;
|
|
protected int currentFrameIndex;
|
|
protected float fps;
|
|
|
|
public Sprite(Handler handler, TextureRegion texture, float x, float y, float width, float height, boolean manual, GameObject gameObj) {
|
|
this.handler = handler;
|
|
this.texture = texture;
|
|
this.bounds = new Rectangle(x, y, width, height);
|
|
this.manual = manual;
|
|
this.gameObj = gameObj;
|
|
|
|
currentFrame = new TextureRegion();
|
|
frames = new TextureRegion[0];
|
|
currentFrameIndex = 0;
|
|
fps = 10.0f;
|
|
}
|
|
|
|
public abstract void update(float dt);
|
|
public abstract void render(SpriteBatch batch);
|
|
public abstract void dispose();
|
|
|
|
//Getters and Setters
|
|
public Rectangle getBounds() {return bounds;}
|
|
public boolean isManual() {return manual;}
|
|
public GameObject getGameObj() {return gameObj;}
|
|
public TextureRegion getTexture() {return texture;}
|
|
public TextureRegion getCurrentFrame() {return currentFrame;}
|
|
public TextureRegion[] getFrames() {return frames;}
|
|
public int getCurrentFrameIndex() {return currentFrameIndex;}
|
|
public float getFps() {return fps;}
|
|
|
|
public void setManual(boolean manual) {this.manual = manual;}
|
|
public void setGameObj(GameObject gameObj) {this.gameObj = gameObj;}
|
|
public void setTexture(TextureRegion image) {this.texture = image;}
|
|
public void setFrames(TextureRegion[] frames) {this.frames = frames;}
|
|
public void setCurrentFrameIndex(int index) {this.currentFrameIndex = index;}
|
|
public void setFps(int fps) {this.fps = fps;}
|
|
}
|