Add: check input text and explode and restart
This commit is contained in:
@@ -39,7 +39,7 @@ function FlyingSaucer(lineIndex) {
|
|||||||
this.wordText = game.add.text(0, 0, "text", style);
|
this.wordText = game.add.text(0, 0, "text", style);
|
||||||
this.wordText.anchor.set(0.5);
|
this.wordText.anchor.set(0.5);
|
||||||
|
|
||||||
this.moveInitialPos();
|
this.startAttack();
|
||||||
|
|
||||||
// this.setActive(true);
|
// this.setActive(true);
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,6 @@ FlyingSaucer.prototype.makeShipBody = function(posX, posY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.prototype.update = function() {
|
FlyingSaucer.prototype.update = function() {
|
||||||
if(this.isActivated) {
|
if(this.isActivated) {
|
||||||
var deltaTime = game.time.elapsed / 1000;
|
var deltaTime = game.time.elapsed / 1000;
|
||||||
@@ -91,12 +90,16 @@ FlyingSaucer.prototype.update = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.prototype.setup = function(wordLevel, speedLevel) {
|
FlyingSaucer.prototype.setup = function(wordLevel, speedLevel) {
|
||||||
this.wordLevel = wordLevel;
|
this.wordLevel = wordLevel;
|
||||||
this.speedLevel = speedLevel;
|
this.speedLevel = speedLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlyingSaucer.prototype.setWord = function(wordText) {
|
||||||
|
this.wordText.text = wordText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.prototype.stop = function() {
|
FlyingSaucer.prototype.stop = function() {
|
||||||
@@ -110,37 +113,30 @@ FlyingSaucer.prototype.setActive = function(isActivated) {
|
|||||||
this.alpha = 1;
|
this.alpha = 1;
|
||||||
} else {
|
} else {
|
||||||
this.alpha = 0;
|
this.alpha = 0;
|
||||||
this.wordText.text = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.moveInitialPos = function() {
|
FlyingSaucer.prototype.moveInitialPos = function() {
|
||||||
console.log("moveInitialPos");
|
|
||||||
this.x = 100 + this.lineIndex * 200;
|
this.x = 100 + this.lineIndex * 200;
|
||||||
this.y = 100;
|
this.y = 100;
|
||||||
|
|
||||||
this.wordText.x = this.x;
|
this.wordText.x = this.x;
|
||||||
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
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.explodeEmitter = game.add.emitter(this.x, this.y, 10);
|
||||||
this.x,
|
|
||||||
this.y,
|
|
||||||
10
|
|
||||||
);
|
|
||||||
this.explodeEmitter.makeParticles('star');
|
this.explodeEmitter.makeParticles('star');
|
||||||
this.explodeEmitter.minParticleScale = 1;
|
this.explodeEmitter.minParticleScale = 1;
|
||||||
this.explodeEmitter.maxParticleScale = 3;
|
this.explodeEmitter.maxParticleScale = 3;
|
||||||
this.explodeEmitter.forEach(
|
this.explodeEmitter.forEach( function(particle) { particle.tint = 0xadff2f; } );
|
||||||
function(particle) {
|
|
||||||
particle.tint = 0xadff2f;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.explodeEmitter.gravity = 0;
|
this.explodeEmitter.gravity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.reset = function() {
|
|
||||||
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.moveInitialPos();
|
this.moveInitialPos();
|
||||||
this.wordText.text = "text";
|
this.setWord("text");
|
||||||
this.setActive(true);
|
this.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,13 +169,14 @@ FlyingSaucer.prototype.checkInputText = function(inputText) {
|
|||||||
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index);
|
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.attack = function(inputText) {
|
FlyingSaucer.prototype.checkWord = function(inputText) {
|
||||||
// console.log("inputText : " + inputText);
|
// console.log("inputText : " + inputText);
|
||||||
// console.log("this.wordText : " + this.wordText);
|
// console.log("this.wordText : " + this.wordText);
|
||||||
|
|
||||||
var word = this.wordText.text;
|
var word = this.wordText.text;
|
||||||
|
|
||||||
if(word == inputText) {
|
if(word == inputText) {
|
||||||
|
this.setWord("");
|
||||||
this.explode();
|
this.explode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -187,10 +184,8 @@ FlyingSaucer.prototype.attack = function(inputText) {
|
|||||||
|
|
||||||
FlyingSaucer.prototype.explode = function(inputText) {
|
FlyingSaucer.prototype.explode = function(inputText) {
|
||||||
this.setActive(false);
|
this.setActive(false);
|
||||||
|
|
||||||
this.explodeEmitter.start(true, 1000, null, 100);
|
this.explodeEmitter.start(true, 1000, null, 100);
|
||||||
|
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
|
||||||
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.reset, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ var WordFlyingSaucer = {
|
|||||||
var count = this.flyingsaucers.length;
|
var count = this.flyingsaucers.length;
|
||||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||||
for(var i = 0; i < count; i++) {
|
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("");
|
this.inputText.canvasInput.value("");
|
||||||
|
|||||||
Reference in New Issue
Block a user