I tried adding an animation to my player but when I place my player In the world he vanishes and I get a greenfoot terminal window saying the image was not found even though I put it in the greenfoot folder can any1 help? ps.its a platformer
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class player here. * * @author (your name) * @version (a version number or a date) */ public class player extends Actor { private int speed = 4; private int vSpeed = 0; private int acceleration = 1; private int jumpStrength = 9; private GreenfootImage moveLeft1 = new GreenfootImage("playerleftrun1.gif"); private GreenfootImage moveLeft2 = new GreenfootImage("playerleftrun2.gif"); private GreenfootImage moveRight1 = new GreenfootImage("playerrightrun1.gif"); private GreenfootImage moveRight2 = new GreenfootImage("playerrightrun2.gif"); private int frame = 1; /** * Act - do whatever the player wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkKeys(); checkfall(); } private void checkKeys() { if (Greenfoot.isKeyDown("left") ) { setImage("player-left.gif"); moveLeft(); } if (Greenfoot.isKeyDown("right") ) { setImage("player-right.gif"); moveRight(); } if (Greenfoot.isKeyDown("up") ) { jump(); } } public void jump() { vSpeed = -jumpStrength; fall(); } public void checkfall() { if(onGround()) { vSpeed = 0; } else{ fall(); } } public boolean onGround() { Actor under = getOneObjectAtOffset( 0, getImage().getHeight() / 2 , platform.class); return under != null; } public void fall() { setLocation ( getX(), getY() + vSpeed); vSpeed = vSpeed + acceleration; } public void moveRight() { setLocation ( getX() + speed, getY() ); animateRight(); } public void animateRight() { if(frame == 1) { setImage(moveRight1); } else if(frame ==2) { setImage(moveRight2); frame = 1; return; } frame ++; } public void moveLeft() { setLocation ( getX() - speed, getY() ); animateLeft(); } public void animateLeft() { if(frame == 1) { setImage(moveLeft1); } else if(frame ==2) { setImage(moveLeft2); frame = 1; return; } frame ++; } }