Hey guys.
Im makin a mario game for my java practice.
Now i have a problem.
I want when i press "right", every 100 nanos, my class image changes.
With the purpose that it looks like he walks.
Can someone tell me how? And you can just call it image 1 and 2.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class small_right here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class small_right extends Mario
{
/**
* Act - do whatever the small_right wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.isKeyDown("right"))
{
move(5);
setImage("small_run_right.png");
//i want here a delay
setImage("small_right.PNG");
if(Greenfoot.isKeyDown("left"))
{
move(-5);
setImage(new GreenfootImage("small_run_left.png"));
setImage(new GreenfootImage("small_left.PNG"));
}
}
}