Add: onClickChocobal
This commit is contained in:
@@ -16,6 +16,7 @@ function Chocoball(index, onClickHandler) {
|
|||||||
|
|
||||||
Chocoball.prototype.initVariables = function(textContent) {
|
Chocoball.prototype.initVariables = function(textContent) {
|
||||||
this.isActivated = false;
|
this.isActivated = false;
|
||||||
|
this.number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chocoball.prototype.drawChocoball = function() {
|
Chocoball.prototype.drawChocoball = function() {
|
||||||
@@ -24,25 +25,26 @@ Chocoball.prototype.drawChocoball = function() {
|
|||||||
this.body = game.add.sprite(x, y, 'choco_body');
|
this.body = game.add.sprite(x, y, 'choco_body');
|
||||||
this.body.scale.set(1);
|
this.body.scale.set(1);
|
||||||
this.body.anchor.set(0.5);
|
this.body.anchor.set(0.5);
|
||||||
this.body.tint = 0xff0000;
|
this.body.tint = 0x553333;
|
||||||
|
// this.body.tint = 0xff0000;
|
||||||
|
|
||||||
this.body.inputEnabled = true;
|
this.body.inputEnabled = true;
|
||||||
this.body.events.onInputDown.add(this.onClick, this);
|
this.body.events.onInputDown.add(this.onClick, this);
|
||||||
|
|
||||||
|
|
||||||
this.number = this.makeNumber("50");
|
this.numberText = this.makeNumber("");
|
||||||
this.body.addChild(this.number);
|
this.body.addChild(this.numberText);
|
||||||
|
|
||||||
this.gloss = game.add.sprite(x, y, 'choco_gloss');
|
this.gloss = game.add.sprite(x, y, 'choco_gloss');
|
||||||
this.gloss.scale.set(1);
|
this.gloss.scale.set(1);
|
||||||
this.gloss.anchor.set(0.5);
|
this.gloss.anchor.set(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chocoball.prototype.makeNumber = function(textContent) {
|
Chocoball.prototype.makeNumber = function(numberText) {
|
||||||
var width = 0;
|
var width = 0;
|
||||||
var height = this.width / 30;
|
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.anchor.set(0.5);
|
||||||
number.lineSpacing = Chocoball.DEFAULT_TEXT_LINE_SPACING_PX;
|
number.lineSpacing = Chocoball.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||||
|
|
||||||
@@ -50,12 +52,15 @@ Chocoball.prototype.makeNumber = function(textContent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Chocoball.prototype.setNumber = function(number) {
|
Chocoball.prototype.setNumber = function(number) {
|
||||||
this.number.text = number;
|
this.number = number;
|
||||||
|
this.numberText.text = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Chocoball.prototype.setActive = function(isActivated) {
|
Chocoball.prototype.setActive = function(isActivated) {
|
||||||
this.isActivated = isActivated;
|
this.isActivated = isActivated;
|
||||||
|
this.body.visible = isActivated;
|
||||||
|
this.gloss.visible = isActivated;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chocoball.prototype.onClick = function() {
|
Chocoball.prototype.onClick = function() {
|
||||||
|
|||||||
@@ -46,12 +46,32 @@ var Game = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initVariables: function() {
|
initVariables: function() {
|
||||||
|
this.firstChocoballArray = this.makeChocoballArray(1, 25);
|
||||||
|
this.secondChocoballArray = this.makeChocoballArray(26, 50);
|
||||||
|
|
||||||
this.chocoballs = new Array();
|
this.chocoballs = new Array();
|
||||||
for(var i = 0; i < 25; i++) {
|
for(var i = 0; i < 25; i++) {
|
||||||
var chocoball = new Chocoball(i, this.onClickChocoball);
|
var chocoball = new Chocoball(
|
||||||
chocoball.setNumber(i);
|
i,
|
||||||
|
(function(chocoball) { this.onClickChocoball(chocoball); }).bind(this)
|
||||||
|
);
|
||||||
|
chocoball.setNumber(this.firstChocoballArray[i]);
|
||||||
this.chocoballs.push(chocoball);
|
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() {
|
back: function() {
|
||||||
@@ -61,12 +81,32 @@ var Game = {
|
|||||||
|
|
||||||
|
|
||||||
onClickChocoball: function(chocoball) {
|
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() {
|
startGame: function() {
|
||||||
this.stopWatch.start();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
gameClear: function() {
|
gameClear: function() {
|
||||||
@@ -75,6 +115,7 @@ var Game = {
|
|||||||
if(!isExperienceMaestroAccount())
|
if(!isExperienceMaestroAccount())
|
||||||
this.updateResultRecord();
|
this.updateResultRecord();
|
||||||
|
|
||||||
|
var missionClearText = new MissionClearText();
|
||||||
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -88,10 +129,14 @@ var Game = {
|
|||||||
if(!isExperienceMaestroAccount())
|
if(!isExperienceMaestroAccount())
|
||||||
this.updateResultRecord();
|
this.updateResultRecord();
|
||||||
|
|
||||||
|
var timeOverText = new TimeOverText();
|
||||||
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
game.time.events.add(Game.GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateResultRecord: function() {
|
updateResultRecord: function() {
|
||||||
|
console.log("update record : " + sessionStorageManager.getRecord());
|
||||||
|
return;
|
||||||
|
|
||||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||||
this.dbConnectManager.updateResultRecord(
|
this.dbConnectManager.updateResultRecord(
|
||||||
sessionStorageManager.getMaestroID(),
|
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');
|
||||||
|
}
|
||||||
@@ -39,18 +39,19 @@
|
|||||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||||
<script src="../../game/lib/score_manager.js"></script>
|
<script src="../../game/lib/score_manager.js"></script>
|
||||||
<script src="../../game/lib/heart_manager.js"></script>
|
<script src="../../game/lib/heart_manager.js"></script>
|
||||||
<script src="../../game/lib/global/global_variables.js?update_date=191224"></script>
|
<script src="../../game/lib/global/global_variables.js"></script>
|
||||||
|
|
||||||
<!-- library source files -->
|
<!-- library source files -->
|
||||||
<script src="../../game/lib/util/number_util.js"></script>
|
<script src="../../game/lib/util/number_util.js"></script>
|
||||||
<script src="../../game/lib/util/record_util.js"></script>
|
<script src="../../game/lib/util/record_util.js"></script>
|
||||||
|
|
||||||
<script src="../../game/lib/text/input_type_text.js?update_date=191224"></script>
|
<script src="../../game/lib/text/input_type_text.js"></script>
|
||||||
<script src="../../game/lib/text/time_over_text.js?update_date=191225"></script>
|
<script src="../../game/lib/text/mission_clear_text.js"></script>
|
||||||
<script src="../../game/lib/text/score_board.js?update_date=191224"></script>
|
<script src="../../game/lib/text/time_over_text.js"></script>
|
||||||
<script src="../../game/lib/text/score_text.js?update_date=191224"></script>
|
<script src="../../game/lib/text/score_board.js"></script>
|
||||||
<script src="../../game/lib/text/screen_top_ui.js?update_date=191224"></script>
|
<script src="../../game/lib/text/score_text.js"></script>
|
||||||
<script src="../../game/lib/text/screen_bottom_ui.js?update_date=191224"></script>
|
<script src="../../game/lib/text/screen_top_ui.js"></script>
|
||||||
|
<script src="../../game/lib/text/screen_bottom_ui.js"></script>
|
||||||
|
|
||||||
<script src="../../game/lib/keyboard_shortcut.js"></script>
|
<script src="../../game/lib/keyboard_shortcut.js"></script>
|
||||||
<script src="../../game/lib/history_record_manager.js"></script>
|
<script src="../../game/lib/history_record_manager.js"></script>
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
|
|
||||||
<script src="../../game/mouse/one_to_fifty/stop_watch.js"></script>
|
<script src="../../game/mouse/one_to_fifty/stop_watch.js"></script>
|
||||||
<script src="../../game/mouse/one_to_fifty/chocoball.js"></script>
|
<script src="../../game/mouse/one_to_fifty/chocoball.js"></script>
|
||||||
|
<script src="../../game/mouse/one_to_fifty/god.js"></script>
|
||||||
|
|
||||||
<script src="../../game/mouse/one_to_fifty/game.js"></script>
|
<script src="../../game/mouse/one_to_fifty/game.js"></script>
|
||||||
<script src="../../game/mouse/one_to_fifty/main.js"></script>
|
<script src="../../game/mouse/one_to_fifty/main.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user