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

2013/6/30

animation and looping images

budianto budianto

2013/6/30

#
i wonder how to make simple sprite code in greenfoot actually iam new in java please any help
davemib123 davemib123

2013/6/30

#
Hi budianto. I am using this: I first define the images and a counter as so:
 private int GoombaCounter;
private final GreenfootImage Gwalk1 = new GreenfootImage("goomba-walk1.gif");
    private final GreenfootImage Gwalk2 = new GreenfootImage("goomba-walk2.gif");
The act method increments a counter and calls the animate method:
 GoombaCounter++;
animateGoomba();
The animate method that I am using is:
public void animateGoomba()
    {
        if(GoombaCounter <=12 )
        {
            setImage(Gwalk1);
            GoombaCounter++;
        }
        if(GoombaCounter > 13 && GoombaCounter <=25 )
        {
            setImage(Gwalk2);
            GoombaCounter++;
        }
        if(GoombaCounter >= 26)
        {
            GoombaCounter = 0;
        }
    }
budianto budianto

2013/6/30

#
thankyou
You need to login to post a reply.