| 1234567891011121314151617181920 |
- /**
- This activity further reinforces the logic that objects don’t need to be visible
- to be detected for collision purposes.
- **/
- //*******************Apple Object - Mouse Click Event******************//
- //When apple is click, move to target x and y
- $this.moveTo(400,285);
- $this.moveTo(mouth.x, mouth.y);
- //********************Apple Object - Update Every Frame***************//
- if($this.isTouching(mouth)){ //check if apple is touching mouth
- $this.remove();
- }
- //****************Ninja Object - Update Every Frame*******************//
- $this.moveForward(5);
- if ($this.y() <= -130 || $this.y() >= 50) {
- $this.flipDirection();
- }
|