Add: stove dial, heat plate
This commit is contained in:
@@ -62,10 +62,16 @@ var Game = {
|
||||
this.meatPlate.anchor.set(0.5);
|
||||
this.meatPlate.smoothed = false;
|
||||
|
||||
this.heatPlate = game.add.image(game.world.centerX, Game.HEAT_PLATE_POSITION_Y, 'heat_plate');
|
||||
this.heatPlate.anchor.set(0.5);
|
||||
this.heatPlate.smoothed = false;
|
||||
this.heatPlate.scale.set(1);
|
||||
// this.heatPlate = game.add.image(game.world.centerX, Game.HEAT_PLATE_POSITION_Y, 'heat_plate');
|
||||
// this.heatPlate.anchor.set(0.5);
|
||||
// this.heatPlate.smoothed = false;
|
||||
// this.heatPlate.scale.set(1);
|
||||
|
||||
this.heatPlate = new HeatPlate(game.world.centerX, Game.HEAT_PLATE_POSITION_Y);
|
||||
this.stoveDial = new StoveDial(80, Game.HEAT_PLATE_POSITION_Y + 50);
|
||||
this.stoveDial.setOnChangeDialLevelHandler(
|
||||
(function(dialLevel) { this.onChangeDialLevel(dialLevel); }).bind(this)
|
||||
);
|
||||
|
||||
this.god = new God(game.world.width - 120, Game.GOD_POSITION_Y + 100, this);
|
||||
|
||||
@@ -112,9 +118,15 @@ var Game = {
|
||||
|
||||
this.meatCount;
|
||||
this.badMeatCount = 0;
|
||||
|
||||
this.burnLevel = HeatPlate.BURN_LEVEL_WEAK;
|
||||
},
|
||||
|
||||
onChangeDialLevel: function(dialLevel) {
|
||||
this.burnLevel = dialLevel;
|
||||
|
||||
this.heatPlate.onChangeDialLevel(dialLevel);
|
||||
},
|
||||
|
||||
back: function() {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
God = function(x, y, mainGame) {
|
||||
God.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
God.prototype.constructor = God;
|
||||
|
||||
function God(x, y, mainGame) {
|
||||
this.mainGame = mainGame;
|
||||
this.isActivated = true;
|
||||
|
||||
@@ -11,10 +14,44 @@ God = function(x, y, mainGame) {
|
||||
// this.events.onInputDown.add(this.onDown, this);
|
||||
|
||||
game.add.existing(this);
|
||||
|
||||
game.physics.startSystem(Phaser.Physics.ARCADE);
|
||||
|
||||
this.fullHeartEmitter = game.add.emitter(x, y - 150, 20);
|
||||
this.fullHeartEmitter.makeParticles("heart_full");
|
||||
this.fullHeartEmitter.minParticleScale = 0.5;
|
||||
this.fullHeartEmitter.maxParticleScale = 0.7;
|
||||
this.fullHeartEmitter.minParticleSpeed.setTo(-150, -700);
|
||||
this.fullHeartEmitter.maxParticleSpeed.setTo(150, -500);
|
||||
this.fullHeartEmitter.gravity = 1500;
|
||||
|
||||
this.emptyHeartEmitter = game.add.emitter(x, y - 150, 20);
|
||||
this.emptyHeartEmitter.makeParticles("heart_empty");
|
||||
this.emptyHeartEmitter.minParticleScale = 0.5;
|
||||
this.emptyHeartEmitter.maxParticleScale = 0.7;
|
||||
this.emptyHeartEmitter.minParticleSpeed.setTo(-150, -700);
|
||||
this.emptyHeartEmitter.maxParticleSpeed.setTo(150, -500);
|
||||
this.emptyHeartEmitter.gravity = 1500;
|
||||
|
||||
this.angryEmitter = game.add.emitter(x, y - 200, 20);
|
||||
this.angryEmitter.makeParticles("smoke");
|
||||
this.angryEmitter.width = 30;
|
||||
this.angryEmitter.height = 30;
|
||||
this.angryEmitter.setRotation(-90, 90);
|
||||
this.angryEmitter.setAlpha(0.1, 0.3);
|
||||
// this.angryEmitter.setScale(0.2, 0.2);
|
||||
this.angryEmitter.minParticleScale = 0.5;
|
||||
this.angryEmitter.maxParticleScale = 1;
|
||||
this.angryEmitter.gravity = -300;
|
||||
|
||||
this.angryEmitter.forEach(
|
||||
function(particle) {
|
||||
particle.tint = 0xf0f0f0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
God.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
God.prototype.constructor = God;
|
||||
|
||||
God.prototype.update = function() {
|
||||
}
|
||||
|
||||
@@ -48,6 +85,8 @@ God.prototype.animateHappy = function(type) {
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
|
||||
this.particleBurst(God.REACTION_HAPPY);
|
||||
}
|
||||
|
||||
God.prototype.animateAngry = function(type) {
|
||||
@@ -60,9 +99,39 @@ God.prototype.animateAngry = function(type) {
|
||||
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
||||
tween.onComplete.add(this.smileAgain, this);
|
||||
tween.start();
|
||||
|
||||
this.particleBurst(God.REACTION_ANGRY);
|
||||
}
|
||||
|
||||
God.prototype.smileAgain = function() {
|
||||
this.scale.set(0.5);
|
||||
this.loadTexture('god_smile');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
God.prototype.particleBurst = function(reaction) {
|
||||
// if(this.fullHeartEmitter.on)
|
||||
// this.fullHeartEmitter.on = false;
|
||||
|
||||
// if(this.emptyHeartEmitter.on)
|
||||
// this.emptyHeartEmitter.on = false;
|
||||
|
||||
switch(reaction) {
|
||||
case God.REACTION_HAPPY:
|
||||
this.fullHeartEmitter.start(true, 900, 100, 15, true);
|
||||
break;
|
||||
|
||||
case God.REACTION_SMILE:
|
||||
this.emptyHeartEmitter.start(true, 900, 100, 15, true);
|
||||
break;
|
||||
|
||||
case God.REACTION_ANGRY:
|
||||
this.angryEmitter.start(true, 900, 100, 15, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
God.REACTION_HAPPY = 0;
|
||||
God.REACTION_SMILE = 1;
|
||||
God.REACTION_ANGRY = 2;
|
||||
@@ -0,0 +1,56 @@
|
||||
HeatPlate.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
HeatPlate.prototype.constructor = HeatPlate;
|
||||
|
||||
function HeatPlate(x, y) {
|
||||
Phaser.Sprite.call(this, game, x, y, 'heat_plate');
|
||||
this.anchor.set(0.5);
|
||||
// this.scale.set(0.5);
|
||||
this.smoothed = false;
|
||||
this.inputEnabled = false;
|
||||
game.add.existing(this);
|
||||
|
||||
// add 3 sprites for flame
|
||||
// this.spriteFlame = game.make.sprite(0, 0, "flame_weak");
|
||||
this.spriteFlame = game.make.sprite(0, 0, "heat_plate_flame");
|
||||
this.spriteFlame.anchor.set(0.5, 0.65);
|
||||
// this.spriteFlame.scale.set(0.5);
|
||||
this.spriteFlame.smoothed = false;
|
||||
this.spriteFlame.alpha = 0.3;
|
||||
|
||||
this.addChild(this.spriteFlame);
|
||||
this.setBurnLevel(HeatPlate.BURN_LEVEL_WEAK);
|
||||
game.add.tween(this.spriteFlame).to( { alpha: 0.8 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
}
|
||||
|
||||
|
||||
HeatPlate.prototype.setBurnLevel = function(burlLevel) {
|
||||
this.burnLevel = burlLevel;
|
||||
|
||||
switch(this.burnLevel) {
|
||||
case HeatPlate.BURN_LEVEL_WEAK:
|
||||
this.spriteFlame.tint = HeatPlate.BURN_COLOR_WEAK;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_NORMAL:
|
||||
this.spriteFlame.tint = HeatPlate.BURN_COLOR_NORMAL;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_STRONG:
|
||||
this.spriteFlame.tint = HeatPlate.BURN_COLOR_STRONG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HeatPlate.prototype.onChangeDialLevel = function(dialLevel) {
|
||||
this.setBurnLevel(dialLevel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HeatPlate.BURN_LEVEL_WEAK = 0;
|
||||
HeatPlate.BURN_LEVEL_NORMAL = 1;
|
||||
HeatPlate.BURN_LEVEL_STRONG = 2;
|
||||
|
||||
HeatPlate.BURN_COLOR_WEAK = 0xfd9466;
|
||||
HeatPlate.BURN_COLOR_NORMAL = 0xbd5915;
|
||||
HeatPlate.BURN_COLOR_STRONG = 0xcd0030;
|
||||
@@ -30,9 +30,15 @@ var Loading = {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
game.load.image('wooden_table', '../../../resources/image/object/grilled_meat/wooden_table.png');
|
||||
game.load.image('heat_plate', '../../../resources/image/object/grilled_meat/heat_plate.png');
|
||||
|
||||
game.load.image('stove_dial', '../../../resources/image/object/grilled_meat/stove_dial.png');
|
||||
game.load.image('stove_dial_dot', '../../../resources/image/object/grilled_meat/stove_dial_dot.png');
|
||||
|
||||
game.load.image('plate', '../../../resources/image/object/grilled_meat/plate.png');
|
||||
|
||||
game.load.image('heat_plate_flame', '../../../resources/image/object/grilled_meat/heat_plate_flame.png');
|
||||
game.load.image('heat_plate', '../../../resources/image/object/grilled_meat/heat_plate.png');
|
||||
|
||||
game.load.image('meat1', '../../../resources/image/object/grilled_meat/meat1.png');
|
||||
game.load.image('meat2', '../../../resources/image/object/grilled_meat/meat2.png');
|
||||
game.load.image('meat3', '../../../resources/image/object/grilled_meat/meat3.png');
|
||||
@@ -51,6 +57,9 @@ var Loading = {
|
||||
game.load.image('speech_bubble_angry', '../../../resources/image/ui/speech_bubble_angry.png');
|
||||
game.load.image('speech_bubble_happy', '../../../resources/image/ui/speech_bubble_happy.png');
|
||||
|
||||
game.load.image('heart_full', '../../../resources/image/ui/heart_full.png');
|
||||
game.load.image('heart_empty', '../../../resources/image/ui/heart_empty.png');
|
||||
|
||||
game.load.image('god_angry', '../../../resources/image/character/god/god_hungry.png');
|
||||
game.load.image('god_smile', '../../../resources/image/character/god/god_smile.png');
|
||||
game.load.image('god_happy', '../../../resources/image/character/god/god_happy.png');
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
StoveDial.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
StoveDial.prototype.constructor = StoveDial;
|
||||
|
||||
function StoveDial(x, y) {
|
||||
Phaser.Sprite.call(this, game, x, y, 'stove_dial');
|
||||
this.anchor.set(0.5);
|
||||
// this.scale.set(0.5);
|
||||
this.smoothed = false;
|
||||
this.inputEnabled = true;
|
||||
game.add.existing(this);
|
||||
|
||||
this.events.onInputDown.add(
|
||||
(function() { this.onDown(); }).bind(this),
|
||||
this
|
||||
);
|
||||
|
||||
this.addDotSprite();
|
||||
|
||||
this.state = HeatPlate.BURN_LEVEL_WEAK;
|
||||
this.setDialLevel();
|
||||
}
|
||||
|
||||
|
||||
StoveDial.prototype.addDotSprite = function() {
|
||||
this.dot = game.make.sprite(0, -27, "stove_dial_dot");
|
||||
this.dot.anchor.set(0.5);
|
||||
this.dot.smoothed = false;
|
||||
this.dot.tint = 0xff0000;
|
||||
this.addChild(this.dot);
|
||||
}
|
||||
|
||||
StoveDial.prototype.onDown = function() {
|
||||
switch(this.state) {
|
||||
case HeatPlate.BURN_LEVEL_WEAK:
|
||||
this.state = HeatPlate.BURN_LEVEL_NORMAL;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_NORMAL:
|
||||
this.state = HeatPlate.BURN_LEVEL_STRONG;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_STRONG:
|
||||
this.state = HeatPlate.BURN_LEVEL_WEAK;
|
||||
break;
|
||||
}
|
||||
|
||||
this.setDialLevel();
|
||||
this.onChangeDialLevel(this.state);
|
||||
}
|
||||
|
||||
StoveDial.prototype.setOnChangeDialLevelHandler = function(eventHandler) {
|
||||
this.onChangeDialLevel = eventHandler;
|
||||
}
|
||||
|
||||
|
||||
StoveDial.prototype.setDialLevel = function() {
|
||||
switch(this.state) {
|
||||
case HeatPlate.BURN_LEVEL_WEAK:
|
||||
this.angle = 30;
|
||||
this.dot.tint = StoveDial.BURN_COLOR_WEAK;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_NORMAL:
|
||||
this.angle = 60;
|
||||
this.dot.tint = StoveDial.BURN_COLOR_NORMAL;
|
||||
break;
|
||||
|
||||
case HeatPlate.BURN_LEVEL_STRONG:
|
||||
this.angle = 90;
|
||||
this.dot.tint = StoveDial.BURN_COLOR_STRONG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StoveDial.BURN_COLOR_WEAK = 0xf7d708;
|
||||
StoveDial.BURN_COLOR_NORMAL = 0xbd5915;
|
||||
StoveDial.BURN_COLOR_STRONG = 0xcd0030;
|
||||
@@ -69,6 +69,8 @@
|
||||
<script src="../../game/mouse/grilled_meat/meat.js"></script>
|
||||
<script src="../../game/mouse/grilled_meat/plus_score.js"></script>
|
||||
<script src="../../game/mouse/grilled_meat/speech_bubble.js"></script>
|
||||
<script src="../../game/mouse/grilled_meat/heat_plate.js"></script>
|
||||
<script src="../../game/mouse/grilled_meat/stove_dial.js"></script>
|
||||
|
||||
<script src="../../game/mouse/grilled_meat/game.js?update=190916"></script>
|
||||
<script src="../../game/mouse/grilled_meat/main.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user