Add: onClickChocobal
This commit is contained in:
@@ -16,6 +16,7 @@ function Chocoball(index, onClickHandler) {
|
||||
|
||||
Chocoball.prototype.initVariables = function(textContent) {
|
||||
this.isActivated = false;
|
||||
this.number = 0;
|
||||
}
|
||||
|
||||
Chocoball.prototype.drawChocoball = function() {
|
||||
@@ -24,25 +25,26 @@ Chocoball.prototype.drawChocoball = function() {
|
||||
this.body = game.add.sprite(x, y, 'choco_body');
|
||||
this.body.scale.set(1);
|
||||
this.body.anchor.set(0.5);
|
||||
this.body.tint = 0xff0000;
|
||||
this.body.tint = 0x553333;
|
||||
// this.body.tint = 0xff0000;
|
||||
|
||||
this.body.inputEnabled = true;
|
||||
this.body.events.onInputDown.add(this.onClick, this);
|
||||
|
||||
|
||||
this.number = this.makeNumber("50");
|
||||
this.body.addChild(this.number);
|
||||
this.numberText = this.makeNumber("");
|
||||
this.body.addChild(this.numberText);
|
||||
|
||||
this.gloss = game.add.sprite(x, y, 'choco_gloss');
|
||||
this.gloss.scale.set(1);
|
||||
this.gloss.anchor.set(0.5);
|
||||
}
|
||||
|
||||
Chocoball.prototype.makeNumber = function(textContent) {
|
||||
Chocoball.prototype.makeNumber = function(numberText) {
|
||||
var width = 0;
|
||||
var height = this.width / 30;
|
||||
|
||||
var number = game.add.text(width, height, textContent, Chocoball.FONT_STYLE);
|
||||
var number = game.add.text(width, height, numberText, Chocoball.FONT_STYLE);
|
||||
number.anchor.set(0.5);
|
||||
number.lineSpacing = Chocoball.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||
|
||||
@@ -50,12 +52,15 @@ Chocoball.prototype.makeNumber = function(textContent) {
|
||||
}
|
||||
|
||||
Chocoball.prototype.setNumber = function(number) {
|
||||
this.number.text = number;
|
||||
this.number = number;
|
||||
this.numberText.text = number;
|
||||
}
|
||||
|
||||
|
||||
Chocoball.prototype.setActive = function(isActivated) {
|
||||
this.isActivated = isActivated;
|
||||
this.body.visible = isActivated;
|
||||
this.gloss.visible = isActivated;
|
||||
}
|
||||
|
||||
Chocoball.prototype.onClick = function() {
|
||||
|
||||
@@ -46,12 +46,32 @@ var Game = {
|
||||
},
|
||||
|
||||
initVariables: function() {
|
||||
this.firstChocoballArray = this.makeChocoballArray(1, 25);
|
||||
this.secondChocoballArray = this.makeChocoballArray(26, 50);
|
||||
|
||||
this.chocoballs = new Array();
|
||||
for(var i = 0; i < 25; i++) {
|
||||
var chocoball = new Chocoball(i, this.onClickChocoball);
|
||||
chocoball.setNumber(i);
|
||||
var chocoball = new Chocoball(
|
||||
i,
|
||||
(function(chocoball) { this.onClickChocoball(chocoball); }).bind(this)
|
||||
);
|
||||
chocoball.setNumber(this.firstChocoballArray[i]);
|
||||
this.chocoballs.push(chocoball);
|
||||
}
|
||||
|
||||
this.god = new God(game.world.width - 120, Game.GOD_POSITION_Y + 100, this);
|
||||
|
||||
this.nextNumber = 1;
|
||||
},
|
||||
|
||||
makeChocoballArray(firstNumber, lastNumber) {
|
||||
var numberArray = new Array();
|
||||
for(var i = firstNumber; i < lastNumber + 1; i++) {
|
||||
numberArray.push(i);
|
||||
}
|
||||
|
||||
var randomArray = Phaser.ArrayUtils.shuffle(numberArray);
|
||||
return randomArray;
|
||||
},
|
||||
|
||||
back: function() {
|
||||
@@ -61,12 +81,32 @@ var Game = {
|
||||
|
||||
|
||||
onClickChocoball: function(chocoball) {
|
||||
console.log(chocoball.index);
|
||||
// console.log(chocoball.index);
|
||||
console.log(chocoball.number);
|
||||
|
||||
if(chocoball.number == 1)
|
||||
this.stopWatch.start();
|
||||
|
||||
if(chocoball.number != this.nextNumber) {
|
||||
console.log("wrong");
|
||||
return;
|
||||
} else {
|
||||
this.nextNumber++;
|
||||
}
|
||||
|
||||
if(chocoball.number < 25)
|
||||
chocoball.setNumber(this.secondChocoballArray[chocoball.index]);
|
||||
else
|
||||
chocoball.setActive(false);
|
||||
|
||||
if(chocoball.number == 50) {
|
||||
console.log("game clear");
|
||||
this.gameClear();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
startGame: function() {
|
||||
this.stopWatch.start();
|
||||
},
|
||||
|
||||
gameClear: function() {
|
||||
@@ -75,6 +115,7 @@ var Game = {
|
||||
if(!isExperienceMaestroAccount())
|
||||
this.updateResultRecord();
|
||||
|
||||
var missionClearText = new MissionClearText();
|
||||
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||
},
|
||||
|
||||
@@ -88,10 +129,14 @@ var Game = {
|
||||
if(!isExperienceMaestroAccount())
|
||||
this.updateResultRecord();
|
||||
|
||||
var timeOverText = new TimeOverText();
|
||||
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||
},
|
||||
|
||||
updateResultRecord: function() {
|
||||
console.log("update record : " + sessionStorageManager.getRecord());
|
||||
return;
|
||||
|
||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||
this.dbConnectManager.updateResultRecord(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
God = function(x, y, mainGame) {
|
||||
this.mainGame = mainGame;
|
||||
this.isActivated = true;
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, 'god_angry');
|
||||
this.anchor.setTo(0.5, 1);
|
||||
this.scale.set(0.5);
|
||||
|
||||
this.inputEnabled = false;
|
||||
// this.input.enableDrag(false);
|
||||
// this.events.onInputDown.add(this.onDown, this);
|
||||
|
||||
game.add.existing(this);
|
||||
}
|
||||
|
||||
God.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
God.prototype.constructor = God;
|
||||
God.prototype.update = function() {
|
||||
}
|
||||
|
||||
|
||||
God.prototype.onDown = function(sprite, pointer) {
|
||||
console.log("onDown : " + pointer.x + ", " + pointer.y);
|
||||
this.animateAngry();
|
||||
}
|
||||
|
||||
God.prototype.isInRect = function(x, y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
God.prototype.onDragStop = function(sprite, pointer) {
|
||||
console.log("onDragStop : " + pointer.x + ", " + pointer.y);
|
||||
}
|
||||
|
||||
God.prototype.setScale = function(size) {
|
||||
this.scale.set(size);
|
||||
this.backupScale = size;
|
||||
}
|
||||
|
||||
|
||||
God.prototype.animateHappy = function(type) {
|
||||
this.loadTexture('god_happy');
|
||||
this.mainGame.speechBubble.showSpeechBubble(type);
|
||||
|
||||
var tween = game.add.tween(this.scale);
|
||||
tween.to({x:0.7, y:0.7}, 500, Phaser.Easing.Quadratic.Out, true, 0);
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
}
|
||||
|
||||
God.prototype.animateAngry = function(type) {
|
||||
this.loadTexture('god_angry');
|
||||
this.mainGame.speechBubble.showSpeechBubble(type);
|
||||
|
||||
var tween = game.add.tween(this.scale);
|
||||
tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Bounce.Out, true, 0);
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
}
|
||||
|
||||
God.prototype.smileAgain = function() {
|
||||
this.scale.set(0.5);
|
||||
this.loadTexture('god_smile');
|
||||
}
|
||||
Reference in New Issue
Block a user