how would i code an actor to move smoothly eg 10 spaces if a button has been pressed once?
int mCount=10;
public void mcount()
{
mCount--;
}
/**
* Act - do whatever the Player2 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
CheckKey();
if(mCount==6)
{
mCount=10;
}
//replace();
//turn();
}
public void CheckKey()
{
if (Greenfoot.isKeyDown("w")&&mCount<=5)
{
setLocation(getX(),getY()-mCount);
mcount();
int mCount;
public void mcount()
{
mCount--;
}
/**
* Act - do whatever the Player2 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
CheckKey();
if(mCount==0)
{
mCount=10;
}
}
public void CheckKey()
{
if (Greenfoot.isKeyDown("w"))
{
mCount= 10;
if(mCount>0)
{
setLocation(getX(),getY()-mCount);
mcount();
}
}/**
* return true if a keyboard key is pressed down
* else return false
*/
public boolean keyPressed()
{
if(Greenfoot.isKeyDown("w")||Greenfoot.isKeyDown("s")||Greenfoot.isKeyDown("a")||Greenfoot.isKeyDown("d"))
return true;
else
return false;
}