Add: HintBubble
Fix: chocoball color Fix: history, ranking DB
This commit is contained in:
@@ -69,7 +69,7 @@ Chocoball.prototype.setBodyColor = function(number) {
|
||||
else if(number < 41)
|
||||
this.body.tint = Chocoball.COLOR_31_TO_40;
|
||||
else
|
||||
this.body.tint = Chocoball.COLOR_41_TO_50;
|
||||
this.body.tint = Chocoball.COLOR_BLACK;
|
||||
|
||||
}
|
||||
|
||||
@@ -91,14 +91,14 @@ Chocoball.prototype.onClick = function() {
|
||||
|
||||
Chocoball.getX = function(index) {
|
||||
if(index == 100)
|
||||
return 840;
|
||||
return 0;
|
||||
|
||||
return 250 + (index % 5) * 70;
|
||||
}
|
||||
|
||||
Chocoball.getY = function(index) {
|
||||
if(index == 100)
|
||||
return 285;
|
||||
return 0;
|
||||
|
||||
return 250 + (Math.floor(index / 5)) * 70;
|
||||
}
|
||||
@@ -128,14 +128,13 @@ Chocoball.FONT_STYLE = {
|
||||
Chocoball.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel
|
||||
Chocoball.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel
|
||||
|
||||
Chocoball.RADIUS = 90;
|
||||
Chocoball.RADIUS = 90;
|
||||
|
||||
Chocoball.COLOR_BLACK = 0x553333;
|
||||
Chocoball.COLOR_1_TO_10 = 0x0090ff; // blue
|
||||
Chocoball.COLOR_11_TO_20 = 0xff2000; // red
|
||||
Chocoball.COLOR_21_TO_30 = 0x00ff30; // green
|
||||
Chocoball.COLOR_31_TO_40 = 0xffff33; // yellow
|
||||
Chocoball.COLOR_41_TO_50 = 0x33ffff; //
|
||||
Chocoball.COLOR_1_TO_10 = 0x3090FF; // blue
|
||||
Chocoball.COLOR_11_TO_20 = 0xD02000; // red
|
||||
Chocoball.COLOR_21_TO_30 = 0xFFFF00; // yellow
|
||||
Chocoball.COLOR_31_TO_40 = 0x00FF00; // green
|
||||
|
||||
Chocoball.MODE_EASY = 0;
|
||||
Chocoball.MODE_DIFFICULT = 1;
|
||||
@@ -57,7 +57,7 @@ var Game = {
|
||||
// if previous record is over 60 sec, play easy mode
|
||||
var prevRecord = sessionStorageManager.getRecord()
|
||||
// console.log(prevRecord);
|
||||
var secForEasyMode = this.mode == "test" ? 1 : 60;
|
||||
var secForEasyMode = this.mode == "test" ? 1 : 40;
|
||||
if(prevRecord > secForEasyMode) {
|
||||
this.difficulty = Chocoball.MODE_EASY;
|
||||
}
|
||||
@@ -86,37 +86,14 @@ var Game = {
|
||||
this.chocoballs.push(chocoball);
|
||||
}
|
||||
|
||||
var triangleStartX = God.POSITION_X;
|
||||
var triangleStartY = God.POSITION_Y - 245;
|
||||
var triangleHalfWidth = 20;
|
||||
var triangleHeight = 40;
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.lineStyle(20, 0x000000);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
graphics.lineStyle(10, 0x000000);
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.drawCircle(God.POSITION_X, God.POSITION_Y - 360, 200);
|
||||
graphics.endFill();
|
||||
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.lineStyle(0);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
this.hintBubble = new HintBubble(God.POSITION_X, God.POSITION_Y - 260);
|
||||
this.nextChocoball = new Chocoball(
|
||||
100,
|
||||
this.difficulty,
|
||||
(function(chocoball) { console.log("no event") }).bind(this)
|
||||
);
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
this.hintBubble.addChild(this.nextChocoball.body);
|
||||
|
||||
this.god = new God(God.POSITION_X, God.POSITION_Y, this);
|
||||
},
|
||||
@@ -165,6 +142,7 @@ var Game = {
|
||||
else
|
||||
chocoball.setVisible(false);
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
this.hintBubble.animateNextHint();
|
||||
|
||||
if(this.mode == "test" && this.nextNumber == 3) {
|
||||
console.log("time over");
|
||||
|
||||
@@ -41,28 +41,20 @@ God.prototype.setScale = function(size) {
|
||||
}
|
||||
|
||||
|
||||
God.prototype.animateHappy = function(type) {
|
||||
God.prototype.animateHappy = function() {
|
||||
this.loadTexture('god_happy');
|
||||
// this.mainGame.speechBubble.showSpeechBubble(type);
|
||||
|
||||
var tween = game.add.tween(this.scale);
|
||||
tween.to({x:0.6, y:0.6}, 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.to({y:0.52}, 500, Phaser.Easing.Quadratic.Out, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
}
|
||||
|
||||
God.prototype.animateAngry = function(type) {
|
||||
God.prototype.animateAngry = function() {
|
||||
this.loadTexture('god_angry');
|
||||
// this.mainGame.speechBubble.showSpeechBubble(type);
|
||||
|
||||
var tween = game.add.tween(this.scale);
|
||||
// tween.to({x:0.7}, 1000, Phaser.Easing.Quadratic.In, true, 0);
|
||||
tween.to({x:0.6}, 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.to({x:0.55}, 500, Phaser.Easing.Bounce.Out, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
}
|
||||
@@ -80,5 +72,5 @@ God.loadResources = function() {
|
||||
|
||||
}
|
||||
|
||||
God.POSITION_X = 840;
|
||||
God.POSITION_Y = 645;
|
||||
God.POSITION_X = 800;
|
||||
God.POSITION_Y = 560;
|
||||
@@ -0,0 +1,76 @@
|
||||
function HintBubble(x, y) {
|
||||
this.posY = y;
|
||||
|
||||
this.bubble = this.makeBubbleSprite(x, y);
|
||||
}
|
||||
|
||||
HintBubble.prototype.makeBubbleSprite = function(x, y) {
|
||||
var graphics = new Phaser.Graphics(game, 0, 0);
|
||||
|
||||
var triangleStartX = 0;
|
||||
var triangleStartY = HintBubble.RADIUS / 7 * 4;
|
||||
var triangleHalfWidth = HintBubble.TRIANGLE_WIDTH / 2;
|
||||
|
||||
// tail outline
|
||||
graphics.lineStyle(HintBubble.STROKE_WIDTH, HintBubble.COLOR_BUBBLE_STROKE);
|
||||
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
// circle
|
||||
graphics.lineStyle(HintBubble.STROKE_WIDTH / 2, HintBubble.COLOR_BUBBLE_STROKE);
|
||||
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
|
||||
graphics.drawCircle(0, 0, HintBubble.RADIUS);
|
||||
graphics.endFill();
|
||||
|
||||
// tail body
|
||||
graphics.lineStyle(0);
|
||||
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
texture = graphics.generateTexture();
|
||||
|
||||
sprite = game.add.sprite(x, y, texture);
|
||||
sprite.anchor.set(0.5);
|
||||
return sprite;
|
||||
}
|
||||
|
||||
HintBubble.prototype.addChild = function(chocoball) {
|
||||
this.bubble.addChild(chocoball);
|
||||
chocoball.y -= HintBubble.TRIANGLE_HEIGHT / 9 * 2;
|
||||
}
|
||||
|
||||
|
||||
HintBubble.prototype.animateNextHint = function() {
|
||||
this.bubble.y = this.posY + HintBubble.ANIMATION_HEIGHT;
|
||||
|
||||
var tween = game.add.tween(this.bubble);
|
||||
tween.to({y:this.posY}, 500, Phaser.Easing.Quadratic.Out, true, 0);
|
||||
tween.onComplete.add(this.animateReset, this);
|
||||
tween.start();
|
||||
}
|
||||
|
||||
HintBubble.prototype.animateReset = function() {
|
||||
this.bubble.y = this.posY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HintBubble.RADIUS = 110;
|
||||
HintBubble.TRIANGLE_HEIGHT = 40;
|
||||
HintBubble.TRIANGLE_WIDTH = 40;
|
||||
|
||||
HintBubble.STROKE_WIDTH = 10;
|
||||
HintBubble.OFFSET_Y = 240;
|
||||
|
||||
HintBubble.ANIMATION_HEIGHT = 20;
|
||||
|
||||
HintBubble.COLOR_BUBBLE_FILL = 0xFFEEEE;
|
||||
HintBubble.COLOR_BUBBLE_STROKE = 0x331122;
|
||||
Reference in New Issue
Block a user