So I was wondering if there was a way to make a variable raise at lets say + 1 ever .5 seconds... I'm still a slight beginner, and never got into the very specialty things when i was learning plain Java...
Thanks in advnace.
public class Actor {
//...(your normal instance variables)
//add this after your normal variables.
private int frameNum;
//...(methods)
public void act()
{
//...do whatever you want it to do....
//...but make sure to add animate()
animate();
}
//This is where you will animate the Actor.
private void animate()
{
if(frameNum == 0) {setImage(whateverImageYouUse);}
else if(frameNum == 20) {setImage(whateverImageYouUse2);}
//...and so on, until you get to the last image:
else if(frameNum == 40) {
setImage(lastImageYouUse);
frameNum = 0;
}
//this is where you update the frameNum
frame++;
}
} private void animate()
{
if(frameNum == 0)
{
setImage(image1);
}
else if(frameNum == 20)
{
setImage(image2);
}
else if(frameNum == 39)
{
setImage(image1);
frameNum = 0;
}
frame ++;
}
}