Open samreid opened 6 years ago
I noticed this code in BAAGameModel.js
this.bestScores = []; // Properties that track progress on each game level.
this.scores = []; // Properties that track score at each game level
this.bestTimeVisible = []; // Properties that track whether to show best time at each game level
self.bestTimes = []; // Best times at each level.
_.times( ShredConstants.LEVEL_NAMES.length, function() {
self.bestScores.push( new Property( 0 ) );
self.scores.push( new Property( 0 ) );
self.bestTimes.push( new Property( null ) );
self.bestTimeVisible.push( new Property( false ) );
} );
It seems it may be better to reorganize this around the idea of each level. For instance, something like:
this.levels =[];
_.times( ShredConstants.LEVEL_NAMES.length, function() {
this.levels.push(new Level()); // Level keeps track of its own score, bestTime, etc.
} );
Next problem: the names of the levels are not amenable to tandemizing (they use hyphens instead of camel case):
LEVEL_NAMES: [ 'periodic-table-game', 'mass-and-charge-game', 'symbol-game', 'advanced-symbol-game' ],
I tried tandemizing the Property values in the _.times but it did not solve anything.
This code in BAAGameScreenView creates a snapshot of Property values and does not dynamically update, it may explain the disconnect (at least for LevelCompleted):
// Add the dialog node that indicates that the level has been completed.
rootNode.addChild( new LevelCompletedNode(
gameModel.levelProperty.get(),
gameModel.scoreProperty.get(),
BAAGameModel.MAX_POINTS_PER_GAME_LEVEL,
BAAGameModel.CHALLENGES_PER_LEVEL,
gameModel.timerEnabledProperty.get(),
gameModel.elapsedTimeProperty.get(),
gameModel.bestTimes[ gameModel.levelProperty.get() ].value,
gameModel.newBestTime,
function() { gameModel.stateProperty.set( BAAGameState.CHOOSING_LEVEL ); }, {
centerX: self.layoutBounds.width / 2,
centerY: self.layoutBounds.height / 2,
levelVisible: false,
maxWidth: self.layoutBounds.width,
tandem: tandem.createTandem( 'levelCompletedNode' )
}
) );
}
It's been great to have @jbphet's help on this, I'll put on hold until we resume collaboration.
Stars not saved
See #156