edb8b43020
Fix: chocoball color Fix: history, ranking DB
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
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; |