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

2014/6/6

timer based movement

dale1 dale1

2014/6/6

#
public int timer = 10; public void act() { checkKeypress(); Time(); Pipetouch(); } public void Time(){ if(timer < 0) { timer= timer -1; } } public void Pipetouch() { if (isTouching(Upipie.class)){ { setLocation(getX(), getY()+3); } } if (isTouching(Spipe.class)){ //if (timer 10){ //setLocation(getX()+3, getY()); //} if ( time>=5){ setLocation(getX()-3, getY()); } } //if (isTouching(Spipe2.class)){ // setLocation(getX()-3, getY()); } i am trying to do is making a timer if the time is less than 5 move left if greater move right but only touching one object.
You need to login to post a reply.