HeatPlate.prototype = Object.create(Phaser.Sprite.prototype); HeatPlate.prototype.constructor = HeatPlate; function HeatPlate() { Phaser.Sprite.call(this, game, HeatPlate.POSITION_X, HeatPlate.POSITION_Y, 'heat_plate'); this.anchor.set(0.5); this.smoothed = false; this.inputEnabled = false; game.add.existing(this); this.spriteFlame = game.make.sprite(0, 0, "heat_plate_flame"); this.spriteFlame.anchor.set(0.5, 0.65); 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.prototype.isOver = function(x, y) { var halfWidth = (this.width - HeatPlate.HANDLE_WIDTH) / 2; var halfHeight = this.height / 2; if(x < this.x - halfWidth) { return false; } else if(this.x + halfWidth < x) { return false; } else if(y < this.y - halfHeight + HeatPlate.START_OFFSET_Y) { return false; } else if(this.y + halfHeight + HeatPlate.START_OFFSET_Y - HeatPlate.HEIGHT < y) { return false; } return true; } HeatPlate.POSITION_X = GAME_SCREEN_SIZE.x / 2 + 70; HeatPlate.POSITION_Y = GAME_SCREEN_SIZE.y / 2 + 180; HeatPlate.HANDLE_WIDTH = 440; HeatPlate.START_OFFSET_Y = 80; HeatPlate.HEIGHT = 220; 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;