hello everybody!
I have made an animation for my robot, but when i stop walking it will stay on the picture last used, meaning that half of the time he will not move but the walking image is still showing.
I have tried to make it that if the right key is not pressed he will set the image to stand, but that will make it do that all the time, even when i walk left.
these are the codes I used to animate him.
http://www.greenfoot.org/scenarios/7135
thats the link to the scenario if you want to check it out :D.
thanks in advance.
public int sequence = 0; public GreenfootImage stand = new GreenfootImage("Player_groot_rechts.png"); public GreenfootImage walk1 = new GreenfootImage("Player_groot1.png"); public GreenfootImage walk2 = new GreenfootImage("Player_groot2.png"); public GreenfootImage standL = new GreenfootImage("Player_groot_links.png"); public GreenfootImage walk3 = new GreenfootImage("Player_groot3.png"); public GreenfootImage walk4 = new GreenfootImage("Player_groot4.png");
private void animator() { if (Greenfoot.isKeyDown("right")) { sequence++; switch (sequence) { case 1: setImage(walk1); break; case 6: setImage(stand); break; case 11: setImage(walk2); break; case 16: sequence = 0; break; } } if (Greenfoot.isKeyDown("left")) { sequence++; switch (sequence) { case 1: setImage(walk3); break; case 6: setImage(standL); break; case 11: setImage(walk4); break; case 16: sequence = 0; break; } } }