Add: check input text and explode and restart

This commit is contained in:
2019-01-04 17:04:34 +09:00
parent 854d1c9a8d
commit 1aeff26072
2 changed files with 17 additions and 22 deletions
@@ -39,7 +39,7 @@ function FlyingSaucer(lineIndex) {
this.wordText = game.add.text(0, 0, "text", style);
this.wordText.anchor.set(0.5);
this.moveInitialPos();
this.startAttack();
// this.setActive(true);
}
@@ -76,7 +76,6 @@ FlyingSaucer.prototype.makeShipBody = function(posX, posY) {
}
FlyingSaucer.prototype.update = function() {
if(this.isActivated) {
var deltaTime = game.time.elapsed / 1000;
@@ -91,12 +90,16 @@ FlyingSaucer.prototype.update = function() {
}
}
FlyingSaucer.prototype.setup = function(wordLevel, speedLevel) {
this.wordLevel = wordLevel;
this.speedLevel = speedLevel;
}
FlyingSaucer.prototype.setWord = function(wordText) {
this.wordText.text = wordText;
}
FlyingSaucer.prototype.stop = function() {
@@ -110,37 +113,30 @@ FlyingSaucer.prototype.setActive = function(isActivated) {
this.alpha = 1;
} else {
this.alpha = 0;
this.wordText.text = "";
}
}
FlyingSaucer.prototype.moveInitialPos = function() {
console.log("moveInitialPos");
this.x = 100 + this.lineIndex * 200;
this.y = 100;
this.wordText.x = this.x;
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
this.wordText.clearColors();
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0);
this.explodeEmitter = game.add.emitter(
this.x,
this.y,
10
);
this.explodeEmitter = game.add.emitter(this.x, this.y, 10);
this.explodeEmitter.makeParticles('star');
this.explodeEmitter.minParticleScale = 1;
this.explodeEmitter.maxParticleScale = 3;
this.explodeEmitter.forEach(
function(particle) {
particle.tint = 0xadff2f;
}
);
this.explodeEmitter.forEach( function(particle) { particle.tint = 0xadff2f; } );
this.explodeEmitter.gravity = 0;
}
FlyingSaucer.prototype.reset = function() {
FlyingSaucer.prototype.startAttack = function() {
this.moveInitialPos();
this.wordText.text = "text";
this.setWord("text");
this.setActive(true);
}
@@ -173,13 +169,14 @@ FlyingSaucer.prototype.checkInputText = function(inputText) {
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index);
}
FlyingSaucer.prototype.attack = function(inputText) {
FlyingSaucer.prototype.checkWord = function(inputText) {
// console.log("inputText : " + inputText);
// console.log("this.wordText : " + this.wordText);
var word = this.wordText.text;
if(word == inputText) {
this.setWord("");
this.explode();
return;
}
@@ -187,10 +184,8 @@ FlyingSaucer.prototype.attack = function(inputText) {
FlyingSaucer.prototype.explode = function(inputText) {
this.setActive(false);
this.explodeEmitter.start(true, 1000, null, 100);
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.reset, this);
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
}
+1 -1
View File
@@ -138,7 +138,7 @@ var WordFlyingSaucer = {
var count = this.flyingsaucers.length;
if(event.keyCode == Phaser.Keyboard.ENTER) {
for(var i = 0; i < count; i++) {
this.flyingsaucers[i].attack(this.inputText.canvasInput.value());
this.flyingsaucers[i].checkWord(this.inputText.canvasInput.value());
}
this.inputText.canvasInput.value("");