Hello everyone! I faced a problem this night, when i tried to set some images over an actor every 1 sec while he`s pressing the "c" button , but when i run the program, this instantly finishes showing them, like i can see only the last image ( i == 6) . What could be the issue? Thanks !
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Job1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Job1 extends Jobs
{
boolean FinishedCutting = false;
long LastTime, CurrentTime;
private int i;
public void act()
{
Cutting();
}
public void Cutting()
{
if(Greenfoot.isKeyDown("c") == true && FinishedCutting == false )
{
for( i=1; i<=6 ; i++ )
{
setImage( "cut" + i + ".png" );
if( i == 6 ) // checks if all images have been shown
{
FinishedCutting=true;
Bed bed = new Bed();
getWorld().addObject(bed,200,200);
}
if ( Greenfoot.isKeyDown("c") == false ) // checks if C is still pressed
{
return;
}
LastTime = System.currentTimeMillis();
while ( LastTime + 1000 <= System.currentTimeMillis() ) // delay of 1 sec between showing every image
{
}
}
}
if( Greenfoot.isKeyDown("x")) // deletes this object if X is pressed
{
getWorld().removeObject(this);
}
}
}

