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

2012/5/18

Animation problems

dlanni dlanni

2012/5/18

#
I based my animation code for walking to the Right on Danpost's answer in topics 1436 and then combined it with Mik's last video on using delays for walking Left. It doesn't work either way at any ANIM_DELAY. I am posting the game as ProjectV6, if anyone would look at my code in class 'Lana', I would like some help in making it work. The project needs to be opened in Greenfoot usually to see it. I don't know why this is.
danpost danpost

2012/5/18

#
I think you have some extraneous code at the end of one of your classes. That may be why you cannot open it in Greenfoot.
danpost danpost

2012/5/18

#
First, remove the 'startAnimDelay()' method; you really do not need it. Change your 'walkL()' method to the following
public void walkL()
{
    if (animDelay != 0)
    {
        animDelay--;
        if (animDelay != 0) return;
    }
    walkImage = (walkImage + 1) % 4;
    if (walkImage == 0) setImage(walkL1);
    else if (walkImage == 1) setImage(walkL2);
    else if (walkImage == 2) setImage(walkL3);
    else setImage(walkL4);
    animDelay = ANIM_DELAY;
}
and similar for your 'walkR()' method. Then change your ANIM_DELAY value to 10. That should get you closer to what you want.
dlanni dlanni

2012/5/18

#
Yay, it works! Thanks again for all your help. Now all I have to do is draw a few more walking Lanas so it doesn't look so clunky, then implement your collision detection in one of the rooms, then make the NPC cat wander around, then draw a wardrobe and install it and code it, then make GUIs for various choices, then figure out how to use scale, then...all before next Wednesday!
You need to login to post a reply.