Browse Source

State repro bugs fixed

Load_Fix
Robert Chen 11 years ago
parent
commit
1f5b5ff700
  1. 2
      index.html
  2. 1
      js/screens.js
  3. 27
      js/ui.js

2
index.html

@ -1,6 +1,6 @@
<html> <html>
<head> <head>
<title>Turkey Baking Simulator</title> <title>Turkey Cooking Simulator</title>
<style type="text/css"> <style type="text/css">
</style> </style>
</head> </head>

1
js/screens.js

@ -246,7 +246,6 @@ function KitchenScreen( stage, gameState ){
this.uiElems = []; this.uiElems = [];
this.uiElems.push( new WindowUI( stage, gameState ) ); this.uiElems.push( new WindowUI( stage, gameState ) );
new FinalConfirmationUI(stage, gameState );
this.background = new createjs.Bitmap( "res/screens/KitchenScreen/KitchenScreen.png" ); this.background = new createjs.Bitmap( "res/screens/KitchenScreen/KitchenScreen.png" );
stage.addChild( this.background ); stage.addChild( this.background );
console.log(gameState.purchasedItems); console.log(gameState.purchasedItems);

27
js/ui.js

@ -135,10 +135,10 @@ function FinalConfirmationUI(stage, gameState){
this.showFinalConfirm = function(){ this.showFinalConfirm = function(){
console.log("Showing final confirm"); console.log("Showing final confirm");
if( !that.showingConfirm ){ if( !that.showingConfirm ){
that.showingConfirm = true;
stage.addChild( finalImg ); stage.addChild( finalImg );
stage.addChild( noButton ); stage.addChild( noButton );
stage.addChild( yesButton ); stage.addChild( yesButton );
that.showingConfirm = true;
} }
}; };
@ -208,6 +208,7 @@ function OvenUI( stage, gameState ){
var ovenLight = new createjs.Shape(); var ovenLight = new createjs.Shape();
ovenLight.graphics.beginFill( "black" ).drawCircle( 181, 126, 2 ); ovenLight.graphics.beginFill( "black" ).drawCircle( 181, 126, 2 );
var confirmation = new FinalConfirmationUI(stage, gameState );
// Oven light control // Oven light control
this.changeOvenLight = function( state ){ this.changeOvenLight = function( state ){
if( state == "On" ){ if( state == "On" ){
@ -231,15 +232,6 @@ function OvenUI( stage, gameState ){
turkeyStates[i].scaleX = turkeyStates[i].scaleY =1; turkeyStates[i].scaleX = turkeyStates[i].scaleY =1;
turkeyStates[i].x = 75; turkeyStates[i].x = 75;
turkeyStates[i].y = 258; turkeyStates[i].y = 258;
turkeyStates[i].addEventListener( "mouseover", function(){
document.body.style.cursor='pointer';
});
turkeyStates[i].addEventListener( "mouseout", function(){
document.body.style.cursor='default';
});
turkeyStates[i].addEventListener( "click", function(){
gameState.pubsub.publish("ShowFinalConfirm","");
});
} }
var temperatureText = new createjs.Text( "OFF", "40px Arial", "#ff7700" ); var temperatureText = new createjs.Text( "OFF", "40px Arial", "#ff7700" );
@ -491,12 +483,17 @@ function OvenUI( stage, gameState ){
stage.addChild(turkeyStates[0]); stage.addChild(turkeyStates[0]);
for(i in turkeyStates){ for(i in turkeyStates){
stage.addChild(turkeyStates[i]); stage.addChild(turkeyStates[i]);
} }
stage.addChild(panFront); stage.addChild(panFront);
} }
// Pan front goes here // Pan front goes here
stage.addChild( panFront ); stage.addChild( panFront );
//finalize button
stage.addChild( new Button( stage, gameState, 45, 250, 250, 175, null, null, function(){
gameState.pubsub.publish("ShowFinalConfirm","");
} ) );
stage.addChild( doorPeekLightOn); stage.addChild( doorPeekLightOn);
stage.addChild( doorPeekLightOff); stage.addChild( doorPeekLightOff);
@ -515,6 +512,7 @@ function OvenUI( stage, gameState ){
} }
}) ); }) );
stage.addChild( handleBar); stage.addChild( handleBar);
return this; return this;
} }
} }
@ -712,8 +710,8 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou
getName: function(){return that.name;}, getName: function(){return that.name;},
delete: function( stage ){ delete: function( stage ){
gameState.pubsub.publish("RemoveItems", [mouseOut, mouseOver]); gameState.pubsub.publish("RemoveItems", [mouseOut, mouseOver]);
mouseOut.visible = false;
delete gameState.marketItems[that.name]; mouseOver.visible = false;
}, },
draw: function( stage, newx, newy ){ draw: function( stage, newx, newy ){
if( newx && newy ){ if( newx && newy ){
@ -772,13 +770,12 @@ function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg
var button = new createjs.Shape(); var button = new createjs.Shape();
button.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest); button.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest);
button.alpha = 0.5; button.alpha = 0.5;
button.addEventListener( "click", function(){ button.addEventListener( "click", function(){
gameState.pubsub.publish( "Play", "Click" ); gameState.pubsub.publish( "Play", "Click" );
if( !altfunc ){ if( !altfunc ){
gameState.pubsub.publish( eventCmd, arg ); gameState.pubsub.publish( eventCmd, arg );
return; return;
} }
console.log(altfunc);
altfunc(); altfunc();
gameState.pubsub.publish( eventCmd, arg ); gameState.pubsub.publish( eventCmd, arg );
} ); } );

Loading…
Cancel
Save