CamerarMennager.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. onLoad: function () {
  31. this.Camera = this.node.getComponent("cc.Camera");
  32. cc.log("有摄像机吗", this.Camera);
  33. } ,
  34. addTargets: function (node) {
  35. this.Camera.addTarget(node);
  36. cc.log("现在摄像机有多少节点", this.Camera.getTargets());
  37. },
  38. removeTargets: function () {
  39. var arr = this.Camera.getTargets();
  40. // if (arr.length > 0) {
  41. // for (var i = arr.length; i < 0; i--) {
  42. // this.Camera.removeTarget(arr[i]);
  43. // }
  44. // }
  45. cc.log("删除照相机里面的东西", this.Camera.getTargets());
  46. this.Camera._targets = [];
  47. cc.log("相机现在的状况", this.Camera);
  48. },
  49. // start () {
  50. //
  51. // },
  52. // update (dt) {},
  53. });