roonie01 wrote...
but now my actor only faces right
public class Player1 extends Actor
{
// GLOBAL DECLARATIONS
// -------------------
int walkRate = 0;
GreenfootImage Right=new GreenfootImage("mega1.png");
GreenfootImage Left=new GreenfootImage("mega1b.png");
GreenfootImage RightA=new GreenfootImage("mega2b.png");
GreenfootImage LeftA=new GreenfootImage("mega2.png");
int fire=0;
int move=3;
// CONSTRUCTOR // runs one time only
// -----------
public Player1()
{
setImage(Right);
} // end constructor
// ACT METHOD // runs repeatedly
// ----------
public void act()
{
setLocation(getX(),getY());
checkForDirectionalControll();
laser();
walkRate++;
} // end act
public void checkForDirectionalControll()
{
if (Greenfoot.isKeyDown("up"))
{
//says to check for key up and if condition is true move up 3 pixel's
setLocation(getX(),getY()-3);
}//end if
if (Greenfoot.isKeyDown("down"))
{
//says to check for key down and if condition is true move down 3 pixel's
setLocation(getX(),getY()+3);
}//end if
if(Greenfoot.isKeyDown("left")&&(getImage()==Right||getImage()==RightA))
{
//says to set the image to the left image when the left arrow is pressed
walkrate=0;
}
if (Greenfoot.isKeyDown("left"))
{
//says to check for key left and if condition is true move left 3 pixel's
LeftImages();
setLocation(getX()-3,getY());
}//endif
if(Greenfoot.isKeyDown("right")&&(getImage()==Left||getImage()==LeftA))
{
//says to set the image to right image when the right arrow is pressed
//and the walkRate variable = 20
walkRate=0;
}
if (Greenfoot.isKeyDown("right"))
{
//says to check for key right and if condition is true move right 3 pixel's
RightImages();
setLocation(getX()+3,getY());
}//end if
//end checkForDirectionalControll
}
public void RightImages()
{
if(getImage()==Right&&walkRate==10)
{
setImage(RightA);
}
else if(walkRate==0||walkRate==20)
{
setImage(Right);
walkRate=0;
}
}
public void LeftImages()
{
if(getImage()==Left&&walkRate==10)
{
setImage(LeftA);
}
else if(walkRate==0||walkRate==20)
{
setImage(Left);
walkRate=0;
}
}