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

2016/9/4

I can't slow down my enemies animation.

heeyyyoooopatty heeyyyoooopatty

2016/9/4

#
I already tried everything but the animation is still fast as hell. Im new to green foot so I'm not familiar with its codes need replies ASAP :( thank you in advance!
public class Enemy2 extends Actor
{
    GreenfootImage ptt1 = new GreenfootImage("ptt1.PNG");
    GreenfootImage ptt2 = new GreenfootImage("ptt2.PNG");
    GreenfootImage ptt3 = new GreenfootImage("ptt3.PNG");
    GreenfootImage ptt4 = new GreenfootImage("ptt4.PNG");
    GreenfootImage ptt5 = new GreenfootImage("ptt5.PNG");
    public int frame = 1;
    public int animationCounter = 0;
    /**
     * Act - do whatever the Enemy2 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        animate ();
if(animationCounter % 6 == 0)
{
}
}
    
    public void animate ()
    {
        if (frame == 1)
    {
        setImage(ptt1);
        frame = 2;
    }
   else if (frame ==2)
   {
       setImage(ptt2);
       frame = 3;
    }
    else if (frame == 3)
    {
        setImage(ptt3);
        frame = 4;
    }
    else if (frame == 4)
    {
        setImage(ptt4);
        frame = 5;
    }
    else if (frame == 5)
    {
        setImage(ptt5);
        frame = 1;
    }
}
}
danpost danpost

2016/9/4

#
heeyyyoooopatty wrote...
Im new to green foot so I'm not familiar with its codes
You mean that you are not familiar with java (apparently). In the act method, you have the 'animate' method called unconditionally (every act cycle); then, you have a condition (that will always be true as the value of 'animationCounter' never changes an remains at zero) with an empty block of code. To slow down the animation, the 'animate' method must not be called every act cycle; there must be a condition placed on it and the less times that condition is true, the slower your animation will be.
heeyyyoooopatty heeyyyoooopatty

2016/9/4

#
could you give me an example of an code? thank you and yes I am not that familiar with java.
heeyyyoooopatty heeyyyoooopatty

2016/9/4

#
btw, I am only animating an enemy so I don't really know where to put the animate method.
Super_Hippo Super_Hippo

2016/9/4

#
public void act()
{
    animationCounter++;
    if (animationCounter == 6)
    {
        animate();
        animationCounter = 0;
    }
}
heeyyyoooopatty heeyyyoooopatty

2016/9/4

#
Super_Hippo wrote...
public void act()
{
    animationCounter++;
    if (animationCounter == 6)
    {
        animate();
        animationCounter = 0;
    }
}
OMG THANK YOU SO MUCH
You need to login to post a reply.