hallsofvallhalla wrote:
K new problem. How in the hell do you delay a animation???? Like I am drawing an image and I made a for loop to cycle through the images but at a slow enough speed to see. I have tried sleep() but it wont display the images, only the last one. I have tried timer but its all crazy...ughghghg
i usually have trouble with this too. it haven't done much java but one method that might work is to make a variable and draw the animation by what the variable says. like this
Code: Select all
int ani_tracker;
frame_counter++;
if(frame_counter > 0 && frame_counter < 20) ani_tacker = 1;
if(frame_counter > 19 && frame_counter < 40) ani_tracker = 2;
if(ani_tracker == 1) draw(frame1);
if(ani_tracker == 2) draw(frame2;
// and so on...
this is of course pseudo code and you probably need to adjust the values but it works pretty well.
EDIT: opps i forgot to mention that you need to use a timer to regulate frame_counter so that it will add at the same speed. i learned this method from a c++ tutorial but i cant seem to find it.