Ok, so I am trying to create animation everytime the player moves the character. Here is what I have:
It highlights the "time = time + 1" and says variable time might not have been initialized. I am not familiar with this error so please educate me on it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public void act() { int time; if (Greenfoot.isKeyDown( "a" )){ move(- 2 ); time = time + 1 ; if (time == 3 ){ setImage( "Shankmove2.jpg" ); } } if (Greenfoot.isKeyDown( "d" )){ move( 2 ); } } } |