This site requires JavaScript, please enable it in your browser!
Greenfoot back
Nickeybarz
Nickeybarz wrote ...

2015/6/6

Need help with making my actor fly up and then come back down

Nickeybarz Nickeybarz

2015/6/6

#
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
danpost danpost

2015/6/6

#
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.
Nickeybarz Nickeybarz

2015/6/7

#
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); } } }
Nickeybarz Nickeybarz

2015/6/7

#
here is the code the bounce and fall is what i need help with i am trying to make it play like doodle jump please help me i am new greenfoot ....
danpost danpost

2015/6/7

#
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).
Nickeybarz Nickeybarz

2015/6/7

#
sorry can you write that in code i don't understand what are saying please asap
danpost danpost

2015/6/7

#
Nickeybarz wrote...
sorry can you write that in code i don't understand what are saying please asap
I am not supplying (and did not suggest to add) any more code than you already have.
You need to login to post a reply.