Add: Chocoball
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
@@ -0,0 +1,75 @@
|
||||
// Chocoball.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
// Chocoball.constructor = Chocoball;
|
||||
|
||||
function Chocoball(index) {
|
||||
this.isActivated = false;
|
||||
|
||||
this.row = Math.floor(index / 5);
|
||||
this.col = index % 5;
|
||||
|
||||
var x = 200 + this.col * 100;
|
||||
var y = 200 + this.row * 100;
|
||||
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.gloss = game.add.sprite(x, y, 'choco_gloss');
|
||||
this.gloss.scale.set(1);
|
||||
this.gloss.anchor.set(0.5);
|
||||
|
||||
this.number = this.makeNumber("50");
|
||||
this.body.addChild(this.number);
|
||||
|
||||
// game.add.existing(this);
|
||||
// game.physics.arcade.enable(this);
|
||||
|
||||
// this.halfWidth = this.width / 2;
|
||||
|
||||
this.setActive(true);
|
||||
}
|
||||
|
||||
Chocoball.prototype.makeNumber = function(textContent) {
|
||||
var width = 0;
|
||||
var height = this.width / 30;
|
||||
|
||||
var number = game.add.text(width, height, textContent, Chocoball.FONT_STYLE);
|
||||
number.anchor.set(0.5);
|
||||
number.lineSpacing = Chocoball.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
Chocoball.prototype.setNumber = function(number) {
|
||||
this.number.text = number;
|
||||
}
|
||||
|
||||
|
||||
Chocoball.prototype.setActive = function(isActivated) {
|
||||
this.isActivated = isActivated;
|
||||
}
|
||||
|
||||
Chocoball.loadResources = function() {
|
||||
game.load.image('choco_gloss', '../../../resources/image/object/one_to_fifty/choco_gloss.png');
|
||||
game.load.image('choco_body', '../../../resources/image/object/one_to_fifty/choco_body.png');
|
||||
}
|
||||
|
||||
|
||||
// Chocoball.DEFAULT_SPEED = 400;
|
||||
|
||||
Chocoball.IMAGE_SIZE = 90;
|
||||
Chocoball.IMAGE_CENTER = Chocoball.IMAGE_SIZE / 2;
|
||||
|
||||
Chocoball.FONT_STYLE = {
|
||||
font: "50px Arial",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
boundsAlignV: "middle", // top, middle, bottom
|
||||
fill: "#fff",
|
||||
fontWeight: "bold",
|
||||
stroke: "rgba(0, 0, 0, 0.5)", // "#333", // "#000",
|
||||
strokeThickness: 8,
|
||||
align: "center"
|
||||
};
|
||||
|
||||
Chocoball.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel
|
||||
Chocoball.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel
|
||||
@@ -30,6 +30,14 @@ var Game = {
|
||||
this.stopWatch = new StopWatch(game);
|
||||
|
||||
|
||||
this.chocoballs = new Array();
|
||||
for(var i = 0; i < 25; i++) {
|
||||
var chocoball = new Chocoball(i);
|
||||
chocoball.setNumber(i);
|
||||
this.chocoballs.push(chocoball);
|
||||
}
|
||||
|
||||
|
||||
this.initVariables();
|
||||
|
||||
// game stage
|
||||
|
||||
@@ -34,6 +34,8 @@ var Loading = {
|
||||
game.load.image('card_front', '../../../resources/image/ui/card_front.png');
|
||||
game.load.image('card_edge', '../../../resources/image/ui/card_selected.png');
|
||||
|
||||
Chocoball.loadResources();
|
||||
|
||||
// game.load.image('a', '../../../resources/image/icon/fullscreen_white.png');
|
||||
// game.load.image('b', '../../../resources/image/icon/fullscreen_white.png');
|
||||
// game.load.image('c', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<script src="../../game/mouse/one_to_fifty/loading.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/game.js"></script>
|
||||
<script src="../../game/mouse/one_to_fifty/main.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user