| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- The ninja can activate the objects either by clicking or by dragging.
- This example solution uses dragging.
- Decomposition:
- * variable created to count supplies
- *
- */
- //****************Scene Object: Initialize When Scene Starts Event***************//
- $this.totalSupplies = 0;
- //******************Scene Object: Update Every Frame Event***********************//
- if ($this.totalSupplies >= 4) {
- //animate on ship sprite
- spaceShip.animation("thrust");
- spaceShip.incrementAnimation();
- rocket.moveY(-100);
- }
- //***************supply_1 Object: Mouse Button Up Event*************************//
- if($this.isTouching(rocket)) {
- $this.scene.totalSupplies += 1;
- $this.remove();
- } else {
- //return to original position
- $this.x(44);
- $this.y(436);
- }
- //***********************supply_2 Object: Mouse Button Up Event*******************//
- if($this.isTouching(rocket)) {
- $this.scene.totalSupplies += 1;
- $this.remove();
- } else {
- //return to original position
- $this.x(182);
- $this.y(412);
- }
- //**********************supply_3 Object: Mouse Button Up Event*******************//
- if($this.isTouching(rocket)) {
- $this.scene.totalSupplies += 1;
- $this.remove();
- } else {
- //return to original position
- $this.x(254);
- $this.y(446);
- }
- //************************supply_4 Object: Mouse Button Up Event*******************//
- if($this.isTouching(rocket)) {
- $this.scene.totalSupplies += 1;
- $this.remove();
- } else {
- //return to original position
- $this.x(374);
- $this.y(444);
- }
|