Skip to content

Commit

Permalink
when ball mode selection changes, cancel any balls that have not yet …
Browse files Browse the repository at this point in the history
…been released from the hopper, #109

Signed-off-by: Chris Malley <[email protected]>
  • Loading branch information
pixelzoom committed May 23, 2018
1 parent e6ab523 commit 5937e18
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/intro/model/IntroModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ define( function( require ) {
*/
function IntroModel() {

var self = this;

PlinkoProbabilityCommonModel.call( this );

var bounds = PlinkoProbabilityConstants.HISTOGRAM_BOUNDS;
Expand All @@ -44,6 +46,14 @@ define( function( require ) {
// @private
this.launchedBallsNumber = 0; // number of balls created
this.ballsToCreateNumber = 0; // number of balls in the creation queue

// Stop dispensing balls when the ball mode is changed.
this.ballModeProperty.lazyLink( function( ballMode ) {
if ( self.ballsToCreateNumber > 0 ) {
self.ballsToCreateNumber = 0;
self.isBallCapReachedProperty.set( self.launchedBallsNumber >= MAX_BALLS );
}
} );
}

plinkoProbability.register( 'IntroModel', IntroModel );
Expand Down

0 comments on commit 5937e18

Please sign in to comment.