package { import flash.display.Bitmap; public class FridgeView extends TileView { private static const EMOTE_OFFSET_Y:Number = -48; private var animationTime:Number = 0; private var emote:Bitmap; private var showingEmote:Boolean; public function FridgeView(model:FridgeModel, layerIndex:int = 0) { super(model, layerIndex); emote = new (Embeds.embedEmoteSammich)(); emote.x = -emote.width / 2; showingEmote = false; } override public function draw(delta:Number):void { super.draw(delta); if (FridgeModel(model).hasSandwich && !showingEmote) { addChild(emote); showingEmote = true; animationTime = 0; } else if (!FridgeModel(model).hasSandwich && showingEmote) { removeChild(emote); showingEmote = false; } if (showingEmote) { animationTime += delta; emote.y = EMOTE_OFFSET_Y + GraphicsConstants.EMOTE_BOUNCE_HEIGHT - Math.abs(Math.sin(Math.PI * animationTime / GraphicsConstants.EMOTE_BOUNCE_INTERVAL)) * GraphicsConstants.EMOTE_BOUNCE_HEIGHT; } } } }