| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- cc.Class({
- extends: cc.Component,
- properties: {
- isFinishZone:false,
- isOnlyDelect: false,
- speed: 0,
- isSpawnOne:false,
- },
- start() {
- this.speed = -GlobalData.game.GameSpeed;//通过全局变量设置速度
- },
- update(dt) {
- if (GlobalData.game.state !== GlobalData.GameManager.State.Run) {
- return;
- }
- if (GlobalData.game.PlayerState == GlobalData.GameManager.PlayerState.Stop) {
- return;
- }
- this.speed = -GlobalData.game.GameSpeed;
- this.node.x += this.speed * dt;
- // console.log(this.node.getBoundingBoxToWorld().xMin);
- // if(this.node.getBoundingBoxToWorld().xMin <=0){
- // cc.director.pause();
- // }
- // var minValue = this.node.getBoundingBoxToWorld().xMin;
-
- // if(!this.isSpawnOne&&minValue<=0){
- // this.isSpawnOne = true;
- // GlobalData.spawnManager.spawnItem();
- // }
- if(this.isFinishZone&&this.node.getBoundingBoxToWorld().xMin<=350){
- //进入了减速区域
- GlobalData.game.isEnterGameFinishZone = true;
- }
- var disappear = this.node.getBoundingBoxToWorld().xMax < 0;
- if (disappear) {
- if(this.isFinishZone){
- //出了减速区域
- GlobalData.game.isEnterGameFinishZone = false;
- if(GlobalData.game.getHeroControl().PlayerStatesScript.strPlayerStates == 'RideElephantRun'){
- GlobalData.game.getHeroControl().PlayerAnimControl.JumpOutElephant();
- GlobalData.game.getHeroControl().PlayerStatesScript.strPlayerStates = 'NormalRun';
- GlobalData.game.PlayerRunState = GlobalData.GameManager.PlayerRunState.NormalRun;
- cc.find('Canvas').getChildByName('PlayerShadow').scale = 1;
- }
- //重置属性
- GlobalData.gameMode.afterTheEndOfSports();
- }
- // console.log('清除');
- // this.node.destroy();
- if (this.isOnlyDelect) {
- //单纯的清除自己
- this.node.destroy();
- } else {
- //场景清除后接着生成,会影响场景生成
- GlobalData.spawnManager.despawnPipe(this);
- }
- }
- }
- });
|