I am trying to get animated water tile and I cannot figure it out..
Here, I try to use the modulus to get the remainder and switch it from there, I set it up like I would in my player walking animation. Here is the code I try to use to get it to fluctuate.
public void update() {
if (anim < 1000000) anim++;
else anim = 0;
if(anim % 30 > 20) {
sprite = Sprite.water_;
} else {
sprite = Sprite.water;
}
}
Then within my Main class I put in private WaterTile water; and called it, and put it in my update() method but it decides to not work.
If you would like to look at my overall code, here are my classes involved..:
- Game.java http://pastebin.com/6sTePyx0
- Tile.java http://pastebin.com/ZtGwdcmt
- Sprite.java http://pastebin.com/e7yt9gek
- WaterTile.java http://pastebin.com/EMezX4QQ