Hi ! It`s me again :D . I rebuit the code for this actor , but after i keep pressing the C button on my keyboard and i lift it at a random moment , i get an weird error
My code :
Error :
I think this error has to deal something with the fact that the compiler cannot find the Actor, but the actor is there :D
Help me fix this ! Thank you!
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, j, bar_number;
private int CutDelay = 50;
public void act()
{
if( Greenfoot.isKeyDown("c") && FinishedCutting == false)
Cutting();
}
public void Cutting()
{
for ( bar_number = 1 ; bar_number <=4 ; bar_number++ )
{
for( i=1 ; i<=10;i++)
{
setImage("cuts/cut" + bar_number + "_" + i + ".png" );
if( Greenfoot.isKeyDown("c") == false )
{ getWorld().removeObject(this);}
LastTime = System.currentTimeMillis();
while ( LastTime + CutDelay >= System.currentTimeMillis() ) {}
getWorld().repaint();
}
for(i=9 ; i>=1 ;i-- )
{
setImage("cuts/cut" + bar_number + "_" + i + ".png" );
if( Greenfoot.isKeyDown("c") == false )
{ getWorld().removeObject(this);}
LastTime = System.currentTimeMillis();
while ( LastTime + CutDelay >= System.currentTimeMillis() ) {}
getWorld().repaint();
}
}
if( bar_number == 4)
{
getImage().clear();
goToNextPoint();
FinishedCutting = true;
}
}
private void goToNextPoint()
{
getWorld().removeObjects( getWorld().getObjects(Bars.class));
}
private void DisplayText()
{
if( Greenfoot.isKeyDown("x") == true )
{
getWorld().removeObject(this);
}
}
}
java.lang.NullPointerException at Job1.Cutting(Job1.java:35) at Job1.act(Job1.java:20) at greenfoot.core.Simulation.actActor(Simulation.java:567) at greenfoot.core.Simulation.runOneLoop(Simulation.java:530) at greenfoot.core.Simulation.runContent(Simulation.java:193) at greenfoot.core.Simulation.run(Simulation.java:183)
