Hi, I have a problem here. And it is a frustrating one.
I try to make a method called animate(), which takes two arguments. With the arguments, the animate method would look like this: animate(GreenfootImage array, int someNumber).
I have found a method to animate an array from Greenfoot blog, thanks to danpost. danpost method, the animation() works. But when I try to modify so that it would take an arguments it does not work.
Please help my animate() method thanks
import greenfoot.*;
public class Kanye extends Actor
{
GreenfootImage[] KanyeIdle = new GreenfootImage[10];
int numOfImgs_KanyeIdle;
//constructor to initialize Kanye
public Kanye(GreenfootImage[] init) {
setImage( KanyeIdle[0] );
}
public Kanye() {
for ( int i = 0; i < KanyeIdle.length; i++ ) {
KanyeIdle[i] = new GreenfootImage("KanyeIdle" + i);
}
}
/**
* Act - do whatever the Kanye wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
animate(KanyeIdle, numOfImgs_KanyeIdle);
}
public void animate(GreenfootImage[] spriteImgs, int numOfImgs) {
numOfImgs = (numOfImgs + 1) % spriteImgs.length;
setImage(spriteImgs[numOfImgs]);
}
public void animation() {
numOfImgs_KanyeIdle = (numOfImgs_KanyeIdle + 1) % KanyeIdle.length;
setImage(KanyeIdle[numOfImgs_KanyeIdle]);
}
}


