cannon.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Learn cc.Class:
  2. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
  10. let Player = require("player")
  11. cc.Class({
  12. extends: cc.Component,
  13. properties: {
  14. player:{
  15. default:null,
  16. type:Player //这里的类型就不再是cc.node,而是脚本组件的类型Player
  17. }
  18. // foo: {
  19. // // ATTRIBUTES:
  20. // default: null, // The default value will be used only when the component attaching
  21. // // to a node for the first time
  22. // type: cc.SpriteFrame, // optional, default is typeof default
  23. // serializable: true, // optional, default is true
  24. // },
  25. // bar: {
  26. // get () {
  27. // return this._bar;
  28. // },
  29. // set (value) {
  30. // this._bar = value;
  31. // }
  32. // },
  33. },
  34. // LIFE-CYCLE CALLBACKS:
  35. // onLoad () {},
  36. start () {
  37. let player = this.player;
  38. console.log(player);
  39. player.fire();
  40. },
  41. // update (dt) {},
  42. });