| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // Learn cc.Class:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
- // Learn Attribute:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
- const PlayerStateStatic = require('PlayerState');
- const GameStatesStatic = require('GameStates');
- cc.Class({
- extends: cc.Component,
- properties: {
- HeroP: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- type: cc.Prefab // to a node for the first time
- },
- LevelP: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- type: cc.Prefab // to a node for the first time
- },
- // bar: {
- // get () {
- // return this._bar;
- // },
- // set (value) {
- // this._bar = value;
- // }
- // },
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad : function() {
- this.CamerarMennager = cc.find("CamerarMennager");
- cc.log("游戏开始le ",this.CamerarMennager);
- this.Hero = cc.instantiate(this.HeroP);
- this.Level = cc.instantiate(this.LevelP);
- this.initGame();
- },
- initGame : function () {
- setTimeout(function () {
- this.addHero();
- cc.find('TouchLayout').getComponent('NodeTouch').count = 0;
- }.bind(this),0)
- },
- addHero : function (data) {
- cc.find('Canvas').getComponent('GameStates').CurrentProgress = GameStatesStatic.GameProgress.default;
- this.CamerarMennager.parent = cc.director.getScene();
- if (cc.find("Hero")!=null) {
- // cc.log("有没有什么镜头",);
- cc.find("Hero").getComponent("PlayerState").CurrentInZoneType = PlayerStateStatic.ZoneType.None;
- cc.find("Hero").destroy();
- this.Hero = cc.instantiate(this.HeroP);
- }
- if (cc.find("Level")!=null) {
- cc.find("Level").destroy();
- this.Level = cc.instantiate(this.LevelP);
- }
- this.Level.parent = cc.director.getScene();
- this.Hero.parent = cc.director.getScene();
- if (data == null) {
- this.CamerarMennager.getComponent("CamerarMennager").removeTargets();
- this.CamerarMennager.getComponent("CamerarMennager").addTargets(this.Level);
- this.CamerarMennager.getComponent("CamerarMennager").addTargets(this.Hero);
- this.Hero.setPosition(370+740,640);
- }else{
- }
- this.CamerarMennager.parent = this.Hero;
- },
- // start () {
- //
- // },
- // update (dt) {
- // cc.log(cc.find("Level").getComponent('LevelControl').name);
- // },
- });
|