Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onLoad() {
const manager = cc.director.getCollisionManager();
manager.enabled = true;
this.curState = Gdt.commonInfo.gameState.none;
this.currX = 0;
this.currY = 0;
this.onDrag();
//setting hero pos
this.node.x = 0;
this.node.y = -(this.node.parent.height / 2) + (this.node.height / 2) + 12;
this.setHeroHpPregress();
},
onDrag() {
update(dt) {
if (this.enemyGroup.curState != Gdt.commonInfo.gameState.start) return;
if (this.hP == 0) return;
let ndX = this.node.x;
ndX += dt * this.xSpeed;
if (ndX <= -(this.node.parent.width - this.node.width) / 2) {
ndX = (this.node.parent.width - this.node.width) / 2;
this.xSpeed = -this.xSpeed;
} else if (ndX >= (this.node.parent.width - this.node.width) / 2) {
ndX = (this.node.parent.width - this.node.width) / 2;
this.xSpeed = -this.xSpeed;
} else {
this.node.x = ndX;
};
let scores = this.enemyGroup.getScore();
if (this.enemyType == 1) {
if (scores <= 500000) {
this.node.y += dt * this.ySpeed;
onLoad() {
this.curState = Gdt.commonInfo.gameState.none;
this.isDeadBullet = false;
//初始化无限子弹组
Gdt.common.initObjPool(this, this.bulletInfinite);
//初始化有限子弹组
Gdt.common.batchInitObjPool(this, this.bulletFiniteG);
},
startAction() {
this.curState = Gdt.commonInfo.gameState.start;
//定时生成敌机
for (let i = 0; i < this.enemyG.length; ++i) {
let freqTime = this.enemyG[i].freqTime;
let fName = 'callback_' + i;
this[fName] = function(e) { this.getNewEnemy(this.enemyG[e]) }.bind(this, i);
this.schedule(this[fName], freqTime);
}
},
//重新开始
update(dt) {
if (this.main.curState == Gdt.commonInfo.gameState.start) {
this.bgMove(dt)
}
}
})
onLoad() {
this.score = 0;
this.bombNo = 0;
this.isGameOver = false;
this.scoreDisplay.string = this.score;
this.bombNoDisplay.string = this.bombNo;
this.curState = Gdt.commonInfo.gameState.start;
this.bestScore = Utils.GD.userGameInfo.aircraftWarBestScore || 0;
this.maskBestScore.string = 'Best Score: ' + this.bestScore;
this.bulletGroup.startAction();
this.enemyGroup.startAction();
this.bomb.on(cc.Node.EventType.TOUCH_START, this.bombOnclick, this);
},
bombOnclick() {
onLoad() {
//初始化敌机组
this.curState = Gdt.commonInfo.gameState.none;
Gdt.common.batchInitObjPool(this, this.enemyG);
},
startAction() {
update(dt) {
if (this.bulletGroup.curState != Gdt.commonInfo.gameState.start) return;
this.node.x += dt * this.xSpeed;
this.node.y += dt * this.ySpeed;
if (this.node.y > this.node.parent.height / 2) this.bulletGroup.bulletDied(this.node);
}
})
pauseAction() {
this.enabled = false;
this.curState = Gdt.commonInfo.gameState.pause;
},
resumeAction() {
resumeAction() {
this.enabled = true;
this.curState = Gdt.commonInfo.gameState.start;
},
//暂停