03-02 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. //ninja1 - Mouse Click Event
  2. //for the teaching, we want to ask ninjas what we want to happen
  3. //next we need to know when we want it to happen
  4. //and how will we make this happen -- try to ilicit if()
  5. //should only happen IF ninja is visible
  6. if($this.visible()){
  7. //if the ninja is visible, we'll do the following:
  8. $this.toggleVisible();
  9. $this.scene.score+=1;
  10. lblScore.text($this.scene.score);
  11. }
  12. //Scene - initialize when scene starts
  13. $this.score = 0;
  14. //following code is pre-populated:
  15. if($this.scene.state() == "PLAY"){
  16. var ninjaTime1 = random(3000, 1000)
  17. createTimer(ninjaTime1, function(){
  18. ninja_1.toggleVisible();
  19. });
  20. var ninjaTime2 = random(3000, 1000)
  21. createTimer(ninjaTime2, function(){
  22. ninja_2.toggleVisible();
  23. });
  24. var ninjaTime3 = random(3000, 1000)
  25. createTimer(ninjaTime3, function(){
  26. ninja_3.toggleVisible();
  27. });
  28. var ninjaTime4 = random(3000, 1000)
  29. createTimer(ninjaTime4, function(){
  30. ninja_4.toggleVisible();
  31. });
  32. }