It can still be made to work by adding a String field for the current direction:
and using something like this:
However, with the current Pirate class code above, you could remove line 27 and just change lines 41 and 46 to use 'iHurt' in place of the number in the image filename.
1 | private String direction = "right" ; |
1 | setImage( "pirate" +direction+iHurt+ ".png" ); |