i need help asap i need help with making the actor fly up when he touches the platform and then come back down i dont want to use setlocation because it look really laggy is their anyother way please help
You could use 'move' instead; but in using it, you 'flatten' the movement (that is: when using 'move(1)' you are limited to 8 possible directions to move in; using 'move(2)', you are limited to 16; etc.). Using 'setLocation', you have more control of what the endpoint would be for each movement. If you post the code you are trying to use, maybe one of us can assist in reducing, or even eliminating, that 'really laggy' look.
public class doodler extends Play
{
/**
* Act - do whatever the doodler wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move();
flyaround();
bounce();
fall();
}
public void move()
{
if(Greenfoot.isKeyDown("left"))
{
move(-12);
setRotation(-0);
}
if(Greenfoot.isKeyDown("right"))
{
move(12);
setRotation(0);
}
}
public void flyaround()
//can fly out of the world's bounds
{
if(getX() == 0){
//fly out to the right
setLocation(getWorld().getWidth() - 1, getY());
}else if(getX() + 1 >= getWorld().getWidth()){
//fly out to the left
setLocation(0, getY());
}
}
public void bounce()
{
if(isTouching(platform.class)){
setLocation(getX(),getY()-150);
Greenfoot.delay(4);
}
}
public void fall()
{
if(!isTouching(platform.class)){
setLocation(getX(),getY()+75);
}
}
}
First, make sure your speed slider is set to around the middle of the slide bar. Then, make the distances that the actor falls and bounces (as well as left and right movement) much smaller values (this includes the '-12' and '12' for left in right in the 'move' method and the '-150' and the '75' in the 'bounce' and 'fall' methods).