I can't seem to get my character to change to the back sprite and move that way
Heres the code:
import greenfoot.*;
// (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class character here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class character extends Actor
{
/**
* Act - do whatever the character wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.isKeyDown("w"))
{
int x = getX();
int y = getY();
setLocation(getX(), getY() + 4);
World world = getWorld();
Actor charback;
world.removeObject(this);
world.addObject(new charback(), x, y);
}else if(Greenfoot.isKeyDown("s"))
{
int x = getX();
int y = getY();
int ny = getY()+4;
setLocation(x,ny);
World world = getWorld();
Actor character;
world.removeObject(this);
world.addObject(new character(), x, y);
}else if (Greenfoot.isKeyDown("d")){
move(4);
int x = getX();
int y = getY();
World world = getWorld();
Actor charright;
world.removeObject(this);
world.addObject(new charright(), x,y);
}else if (Greenfoot.isKeyDown("a")){
move(-4);
int x = getX();
int y = getY();
World world = getWorld();
Actor charleft;
world.removeObject(this);
world.addObject(new charleft(), x,y);
}
}
}

