Hey guys, Im trying to switch between a series of images to show someone walking. I have the pictures, and they are in Libraries > Pictures, and are named Front, Back, Left, and Right, and are numbered from 1-9 as in Front1, Front2, etc.. The code so far that I have is:
I have tried some things that have already been discussed on this website about image switching, but an error message always comes up. Any help or suggestions are very appreciated. Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public class Person extends Actor { public void act() { move(); } public void move() { int y = getY(); int x = getX(); if (Greenfoot.isKeyDown( "up" )) { setLocation(x, y- 3 ); } if (Greenfoot.isKeyDown( "down" )) { setLocation(x, y+ 3 ); } if (Greenfoot.isKeyDown( "left" )) { setLocation(x- 3 , y); } if (Greenfoot.isKeyDown( "right" )) { setLocation(x+ 3 , y); } } } |