stoping frame after 3 slides
this code below this line is looping though 3 pictures. so it will display pic 1, 2, 3, 1, 2, 3,... and so on. but i want it do stop when it picture is 3.
Code :
float frame = 0;
double frame_speed = 0.1; //how fast to loop through pictures
int pictures = 0; //how many pictures to loop from
public void animation_player()
{
int tester = (int)(frame + frame_speed);
if(tester < pictures)
{
frame += frame_speed;
}
else
{
frame = 0;
}
}
Code :
public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
pictures = 3; //6 picture on sheet
g2d.drawImage(player_image, x, y, x+width, y+height,
50*(int)frame, 147, 50*(int)frame+50, 189 ,Sprite_Sheet.m1);
}
iam thinging in if statment may be add another else if(tester == 3)...
Re: stoping frame after 3 slides
Quote:
Originally Posted by
hwoarang69
this code below this line is looping though 3 pictures...
I don't see a loop any where.
Re: stoping frame after 3 slides
1st block of code is in a main game loop.
Re: stoping frame after 3 slides
Can you post the code with the loop?
Re: stoping frame after 3 slides
sure,
main.java
Quote:
public void run()
{
while(player_class.isDEAD() == false) //if player is not dead keep going
{
player_class.PLAYER_MOVE(this, ground_class); //player moves
}
}
Re: stoping frame after 3 slides
Looks like the loop will stop when the isDEAD() method returns true. Change the code so it returns true when you want the loop to stop.