Skip to content

Commit

Permalink
Show a darker soccer ball when a ball in the play area has input disa…
Browse files Browse the repository at this point in the history
…bled, see #119
  • Loading branch information
chrisklus committed Apr 1, 2022
1 parent f46fab0 commit 24544f6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
Binary file added images/ballDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions images/ballDark_png.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions images/license.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"license": "contact [email protected]",
"notes": "created by Mariah Hermsmeyer"
},
"ballDark.png": {
"text": [
"Copyright 2022 University of Colorado Boulder"
],
"projectURL": "https://phet.colorado.edu",
"license": "contact [email protected]",
"notes": "created by Mariah Hermsmeyer"
},
"meanAndMedianScreenIcon.png": {
"text": [
"Copyright 2022 University of Colorado Boulder"
Expand Down
28 changes: 24 additions & 4 deletions js/common/view/CAVObjectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import IProperty from '../../../../axon/js/IProperty.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import ballDark_png from '../../../images/ballDark_png.js';

type SelfOptions = {
objectViewType?: CAVObjectType;
Expand Down Expand Up @@ -94,7 +95,14 @@ class CAVObjectNode extends Node {
return node;
};

const childNode = options.objectViewType === CAVObjectType.SOCCER_BALL ? new Image( ball_png ) :
// The dark soccer ball is used for when a ball has input disabled.
const soccerBallNode = new Image( ball_png );
const soccerBallDarkNode = new Image( ballDark_png );
const soccerBallNodes = new Node( {
children: [ soccerBallNode, soccerBallDarkNode ]
} );

const childNode = options.objectViewType === CAVObjectType.SOCCER_BALL ? soccerBallNodes :
options.objectViewType === CAVObjectType.DOT ? createPlotMarker() :
new ShadedSphereNode( options.objectViewType.radius * 2 );
childNode.maxWidth = viewRadius * 2;
Expand Down Expand Up @@ -159,9 +167,21 @@ class CAVObjectNode extends Node {
// ahs been disabled
Property.multilink<[ AnimationMode, number | null, boolean, boolean ]>(
[ casObject.animationModeProperty, casObject.valueProperty, inputEnabledProperty, objectNodesInputEnabledProperty ],
( mode, value, inputEnabled, objectsInputEnabled ) => {
this.inputEnabled = value !== null && mode === AnimationMode.NONE && inputEnabled && objectsInputEnabled;
} );
( mode, value, singleObjectInputEnabled, objectsInputEnabled ) => {
const inputEnabled = value !== null && mode === AnimationMode.NONE && singleObjectInputEnabled && objectsInputEnabled;

// if input is disabled and the ball is in the play area, show the darker version
if ( !inputEnabled && options.objectViewType === CAVObjectType.SOCCER_BALL && value !== null ) {
soccerBallDarkNode.visible = true;
soccerBallNode.visible = false;
}
else {
soccerBallDarkNode.visible = false;
soccerBallNode.visible = true;
}

this.inputEnabled = inputEnabled;
} );
}
else {
this.dragListener = null;
Expand Down

0 comments on commit 24544f6

Please sign in to comment.