Skip to content

Commit

Permalink
relocate answers, disable Solve and Refresh buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 1, 2021
1 parent e26d02b commit 6d5a2ed
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions js/waveGame/view/WaveGameLevelNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,17 @@ class WaveGameLevelNode extends Node {
phetioReadOnly: true
} );

// Next and Refresh buttons do the same thing.
const next = () => {
this.interruptSubtreeInput();
nextButton.visible = false;
faceNode.visible = false;
level.nextChallenge();
};
nextButton.addListener( next );
refreshButton.addListener( next );

const controlPanelChildren = [
refreshButton,
amplitudeControlsSpinner,
faceNode,
nextButton
];

// When the ?showAnswers query parameter is present, add some stuff to assist with development and QA.
// When the ?showAnswers query parameter is present, add a button for immediately solving the challenge.
let solveButton = null;
if ( phet.chipper.queryParameters.showAnswers ) {

// Pressing this button solves the challenge.
const solveButton = new RectangularPushButton( {
solveButton = new RectangularPushButton( {
content: new Text( 'Solve', {
font: DEFAULT_FONT,
fill: 'white'
Expand All @@ -147,18 +136,6 @@ class WaveGameLevelNode extends Node {
}
} );
controlPanelChildren.push( solveButton );

// Shows the answer (amplitudes) for the challenge.
const answerText = new Text( '', {
font: DEFAULT_FONT,
fill: 'red'
} );
controlPanelChildren.push( answerText );

// unlink is not needed.
level.challengeProperty.link( challenge => {
answerText.text = `[${challenge.getAnswerAmplitudes()}]`;
} );
}

const controlPanel = new Panel( new VBox( {
Expand All @@ -176,11 +153,41 @@ class WaveGameLevelNode extends Node {
top: statusBar.bottom + 20
} );

// Next and Refresh buttons do the same thing.
const next = () => {
this.interruptSubtreeInput();
nextButton.visible = false;
faceNode.visible = false;
level.nextChallenge();
refreshButton.enabled = true;
solveButton.enabled = true;
};
nextButton.addListener( next );
refreshButton.addListener( next );

//TODO display the challenge

assert && assert( !options.children, 'WaveGameLevelNode sets children' );
options.children = [ statusBar, controlPanel ];

// When the ?showAnswers query parameter is present, show the answers near the amplitude sliders.
if ( phet.chipper.queryParameters.showAnswers ) {

// Shows the answer (amplitudes) for the challenge.
const answerText = new Text( '', {
font: DEFAULT_FONT,
fill: 'red',
left: layoutBounds.left + 20,
top: statusBar.bottom + 20
} );
options.children.push( answerText );

// unlink is not needed.
level.challengeProperty.link( challenge => {
answerText.text = `[${challenge.getAnswerAmplitudes()}]`;
} );
}

super( options );

// This Node is visible when its level is selected.
Expand All @@ -193,6 +200,8 @@ class WaveGameLevelNode extends Node {
gameAudioPlayer.correctAnswer();
faceNode.visible = true; //TODO animated fade out
nextButton.visible = true; //TODO show after faceNode fades out
refreshButton.enabled = false;
solveButton && ( solveButton.enabled = false );
} );
}
}
Expand Down

0 comments on commit 6d5a2ed

Please sign in to comment.