Game.js 937 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var Game = cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. Life: cc.Node,
  5. AudioMng: cc.Node,
  6. Knife: cc.Node,
  7. Pan: cc.Node
  8. },
  9. statics: {
  10. instance: null
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. onLoad () {
  14. Game.instance = null
  15. this.Life = this.Life.getComponent('Life')
  16. this.Knife = this.Knife.getComponent('Knife')
  17. this.AudioMng = this.AudioMng.getComponent('AudioMng')
  18. this.Life.init()
  19. //添加碰撞
  20. var manager = cc.director.getCollisionManager();
  21. manager.enabled = true;
  22. // manager.enabledDebugDraw = true;
  23. this.node.on('touchstart', (event) => {
  24. if(!this.Life.isEnd) {
  25. this.Life.minus()
  26. this.Knife.shoot()
  27. this.AudioMng.playHitWood()
  28. }
  29. }, this)
  30. },
  31. start () {
  32. },
  33. // update (dt) {},
  34. });