From 02a15f489c39642e987251107d4bb7119eff0bca Mon Sep 17 00:00:00 2001 From: Robert Chen Date: Sat, 30 Nov 2013 02:31:40 -0800 Subject: [PATCH] Fixed market persistence bug --- js/screens.js | 3 ++- js/ui.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/js/screens.js b/js/screens.js index 592b937..4dbce18 100644 --- a/js/screens.js +++ b/js/screens.js @@ -335,6 +335,7 @@ function MarketScreen( stage, gameState ){ this.uiElems = []; this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen", "Click" ) ); + var marketItemKeys = Object.keys(gameState.marketItems); for (var index in marketItemKeys ) { gameState.marketItems[marketItemKeys[index]].draw( stage ); @@ -426,7 +427,7 @@ function EndingScreen( stage, gameState ){ } function ScoreScreen( stage, gameState ){ - var that = this; + var that = this; this.background = new createjs.Bitmap( "res/Main.png" ); stage.addChild( this.background ); diff --git a/js/ui.js b/js/ui.js index 9356936..b7a5db6 100644 --- a/js/ui.js +++ b/js/ui.js @@ -569,9 +569,6 @@ return { secondCounter = 0; } - // move the overlay - console.log("Mood"+mood.x); - if( dayNight.x < -15583 ) dayNight.x = 0; @@ -671,6 +668,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou gameState.turkeyBought = true; gameState.turkeyWeight = weight; gameState.marketItems[ that.name ].delete(); + that.bought = true; gameState.pubsub.publish("Play", {name:"Buy", volume:0.7} ); gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost)) gameState.pubsub.publish("StartTurkeyModel",""); @@ -703,31 +701,33 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou gameState.pubsub.publish( "Play", "Error" ); } }); - mouseOver.visible = false; + var objReturn = { tick: function(){}, getName: function(){return that.name;}, delete: function( stage ){ + that.visible = false; gameState.pubsub.publish("RemoveItems", [mouseOut, mouseOver]); - mouseOut.visible = false; - mouseOver.visible = false; }, draw: function( stage, newx, newy ){ if( newx && newy ){ mouseOut.x = mouseOver.x = newx; mouseOut.y = mouseOver.y = newy; } - + console.log("NewScreen for item "+that.name +" is " +gameState.newScreen ); if( gameState.newScreen == "KitchenScreen" ){ + mouseOutKitchen.visible = true; stage.addChild( mouseOutKitchen ); mouseOverKitchen.visible = false; stage.addChild( mouseOverKitchen ); return; } - stage.addChild( mouseOut ); - stage.addChild( mouseOver ); + if( !that.bought ){ + stage.addChild( mouseOut ); + stage.addChild( mouseOver ); + } } } return objReturn;