This site requires JavaScript, please enable it in your browser!
Greenfoot back
TotalBOSS01
TotalBOSS01 wrote ...

2014/6/27

move delay??

TotalBOSS01 TotalBOSS01

2014/6/27

#
so im trying to get an actor to move after a certain amount of time i think this code should work but it does nothing
   int moveDelay = 0; 
  
   private void move()  
    {  
    moveDelay++;   
    if (moveDelay == 250)  
    {  
        setLocation(getX(), getY()-1); 
        moveDelay = 0;   
    }  
    }
    public void act() 
    {
        
    }    
}
erdelf erdelf

2014/6/27

#
add this in line 14
move();
you have to actually call the method you want to be executed
NikZ NikZ

2014/6/27

#
You also might want to make moveDelay a private int.
You need to login to post a reply.