01-rooftop-runner.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. // Setting the Scene
  2. // Common error is that ninjas add the asset to an existing asset thereby creating a unintended group.
  3. // Teach ninjas to always go back to the scene before pressing the add asset button.
  4. // It's very easy for ninjas to neglect to set roles or speedX, or other properties because they are only looking
  5. // at pictures in the manual. When reading carefully, they should notice that the manual
  6. // asks SpeedX, roles, and positions (x,y, z) are provided for every object
  7. // background z 0
  8. // rooftop z 1
  9. // runner z 5 (higher than rooftops) ensures that it shows up on top
  10. //**************************** rooftop1 - Update Every Frame ********************************/
  11. // rooftop is always moving
  12. // ensure speedX is set to -200
  13. $this.moveX();
  14. if($this.x() <= -800) {
  15. $this.x(1200);
  16. $this.y(random(550,300));
  17. }
  18. //*************************** rooftop1 - Initialize When Scene Starts ***********************/
  19. // sets initial rooftop x and randomizes y (height)
  20. $this.x(0);
  21. $this.y(random(550, 300));
  22. //*************************** rooftop2 - Update When Scene Starts ***************************/