04-02-ballon-protect.js 939 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. This activity is a simple extension of the previous lesson in flipDirection, adding the moveForward() function.
  3. */
  4. //**************circle_1 Object - Update Every Frame*****************//
  5. $this.moveForward(1); // move forward at a speed of 1
  6. if ($this.isTouching(balloon)) {
  7. // if the circle touches the balloon
  8. balloon.remove(); // remove the balloon.
  9. }
  10. if ($this.x() < 30) {
  11. // if the circle is too far left
  12. $this.flipDirection(); // flip its direction.
  13. }
  14. //***************circle_1 Object 0 Mouse Button Up Event************//
  15. $this.flipDirection();
  16. //*****************circle_2 Object - Update Every Frame**************//
  17. $this.moveForward(1);
  18. if($this.isTouching(balloon)){
  19. balloon.remove();
  20. }
  21. if($this.x() > 770){ //review x , y so ninja knows the coordinates referenced
  22. $this.flipDirection();
  23. }
  24. //***************circle_2 Object 0 Mouse Button Up Event************//
  25. $this.flipDirection();