Added ui to the engine and buttons and implemented them in the game fixed also a mouse position problem
This commit is contained in:
parent
515281351c
commit
728a68cc48
35 changed files with 436 additions and 23 deletions
|
|
@ -13,6 +13,8 @@ public class AnimatedTexture extends Texture {
|
|||
private HashMap<String,Texture[]> textures;
|
||||
private String currentAnimation;
|
||||
private int textureId;
|
||||
private int delay;
|
||||
private int delayTimer;
|
||||
|
||||
/**
|
||||
* Create a new empty AnimatedSprite
|
||||
|
|
@ -24,7 +26,8 @@ public class AnimatedTexture extends Texture {
|
|||
super();
|
||||
textures = new HashMap<String,Texture[]>();
|
||||
currentAnimation = null;
|
||||
textureId = -1;
|
||||
textureId = 0;
|
||||
delay = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,6 +39,7 @@ public class AnimatedTexture extends Texture {
|
|||
*/
|
||||
public boolean addAnimation(String name, Texture[] t){
|
||||
if(!textures.containsKey(name)){
|
||||
if(textures.isEmpty())currentAnimation = name;
|
||||
textures.put(name,t);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -81,10 +85,14 @@ public class AnimatedTexture extends Texture {
|
|||
*/
|
||||
public void bindGL() {
|
||||
if(currentAnimation != null){
|
||||
delayTimer++;
|
||||
textures.get(currentAnimation)[textureId].bindGL();
|
||||
textureId++;
|
||||
if(textures.get(currentAnimation).length >= textureId){
|
||||
textureId = 0;
|
||||
if(delayTimer > delay){
|
||||
textureId++;
|
||||
if(textures.get(currentAnimation).length <= textureId){
|
||||
textureId = 0;
|
||||
}
|
||||
delayTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,4 +177,13 @@ public class AnimatedTexture extends Texture {
|
|||
public void setTextureWidth(float texWidth) {
|
||||
textures.get(currentAnimation)[textureId].setTextureWidth(texWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the delay between texures in frame count
|
||||
*
|
||||
* @param d The number of frames to whait until changing texture
|
||||
*/
|
||||
public void setDelay(int d){
|
||||
delay = d;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue