i dont know how to slow down the walking animation of my "Player" character
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | public void act() { if (Greenfoot.isKeyDown( "d" )) this .setLocation( this .getX()+ 7 , this .getY()); if (Greenfoot.isKeyDown( "d" )) this .animateRunRight(); if (Greenfoot.isKeyDown( "a" )) this .setLocation( this .getX()- 7 , this .getY()); if (Greenfoot.isKeyDown( "a" )) this .animateRunLeft(); if (Greenfoot.isKeyDown( "w" )) this .setLocation( this .getX(), this .getY()- 4 ); if (Greenfoot.isKeyDown( "w" )) this .animateRunUp(); if (Greenfoot.isKeyDown( "s" )) this .setLocation( this .getX(), this .getY()+ 4 ); if (Greenfoot.isKeyDown( "s" )) this .animateRunDown(); if (Greenfoot.isKeyDown( "right" )) this .setLocation( this .getX()+ 7 , this .getY()); if (Greenfoot.isKeyDown( "right" )) this .animateRunRight(); if (Greenfoot.isKeyDown( "left" )) this .setLocation( this .getX()- 7 , this .getY()); if (Greenfoot.isKeyDown( "left" )) this .animateRunLeft(); if (Greenfoot.isKeyDown( "up" )) this .setLocation( this .getX(), this .getY()- 4 ); if (Greenfoot.isKeyDown( "up" )) this .animateRunUp(); if (Greenfoot.isKeyDown( "down" )) this .setLocation( this .getX(), this .getY()+ 4 ); if (Greenfoot.isKeyDown( "down" )) this .animateRunDown(); eatPokeball(); } public void initAnimationSprites() { for ( int i = 0 ; i < 4 ; i++) { String filename = "Run" + i + "_90.png" ; RunRight[i] = new GreenfootImage(filename); Greenfoot.delay( 2 ); } for ( int i = 0 ; i < 4 ; i++) { String filename = "Run" + i + "_-90.png" ; RunLeft[i] = new GreenfootImage(filename); Greenfoot.delay( 2 ); } for ( int i = 0 ; i < 4 ; i++) { String filename = "Run" + i + "_0.png" ; RunUp[i] = new GreenfootImage(filename); Greenfoot.delay( 2 ); } for ( int i = 0 ; i < 4 ; i++) { String filename = "Run" + i + "_180.png" ; RunDown[i] = new GreenfootImage(filename); Greenfoot.delay( 2 ); } } public void animateRunRight() { setImage(RunRight[animCounter++ % 4 ]); } public void animateRunLeft() { setImage(RunLeft[animCounter++ % 4 ]); } public void animateRunUp() { setImage(RunUp[animCounter++ % 4 ]); } public void animateRunDown() { setImage(RunDown[animCounter++ % 4 ]); } |