@@ -11,19 +11,18 @@ define( function( require ) {
11
11
'use strict' ;
12
12
13
13
// modules
14
- var inherit = require ( 'PHET_CORE/inherit' ) ;
15
- var vegas = require ( 'VEGAS/vegas' ) ;
14
+ var Dialog = require ( 'SUN/Dialog' ) ;
16
15
var HBox = require ( 'SCENERY/nodes/HBox' ) ;
17
- var VBox = require ( 'SCENERY/nodes/VBox' ) ;
18
16
var Image = require ( 'SCENERY/nodes/Image' ) ;
19
- var RectangularPushButton = require ( 'SUN/buttons/RectangularPushButton' ) ;
20
- var VStrut = require ( 'SCENERY/nodes/VStrut' ) ;
21
- var Dialog = require ( 'SUN/Dialog' ) ;
17
+ var inherit = require ( 'PHET_CORE/inherit' ) ;
22
18
var NumberProperty = require ( 'AXON/NumberProperty' ) ;
23
- var ScoreDisplayNumberAndStar = require ( 'VEGAS/ScoreDisplayNumberAndStar' ) ;
24
- var Text = require ( 'SCENERY/nodes/Text' ) ;
25
19
var PhetFont = require ( 'SCENERY_PHET/PhetFont' ) ;
26
20
var PhetColorScheme = require ( 'SCENERY_PHET/PhetColorScheme' ) ;
21
+ var RectangularPushButton = require ( 'SUN/buttons/RectangularPushButton' ) ;
22
+ var ScoreDisplayNumberAndStar = require ( 'VEGAS/ScoreDisplayNumberAndStar' ) ;
23
+ var Text = require ( 'SCENERY/nodes/Text' ) ;
24
+ var VBox = require ( 'SCENERY/nodes/VBox' ) ;
25
+ var vegas = require ( 'VEGAS/vegas' ) ;
27
26
28
27
// images
29
28
var phetGirlJugglingStarsImage = require ( 'image!VEGAS/phet-girl-juggling-stars.png' ) ;
@@ -33,8 +32,16 @@ define( function( require ) {
33
32
var newLevelString = require ( 'string!VEGAS/newLevel' ) ;
34
33
35
34
// constants
36
- var SCORE_FONT = new PhetFont ( { size : 40 , weight : 'bold' } ) ;
37
- var BUTTON_FONT = new PhetFont ( 24 ) ;
35
+ var DEFAULT_BUTTONS_FONT = new PhetFont ( 16 ) ;
36
+ var DEFAULT_SCORE_DISPLAY_OPTIONS = {
37
+ font : new PhetFont ( { size : 22 , weight : 'bold' } ) ,
38
+ spacing : 6 ,
39
+ starNodeOptions : {
40
+ outerRadius : 20 ,
41
+ innerRadius : 10 ,
42
+ filledLineWidth : 2
43
+ }
44
+ } ;
38
45
39
46
/**
40
47
* @param {number } score
@@ -44,47 +51,64 @@ define( function( require ) {
44
51
function RewardDialog ( score , options ) {
45
52
46
53
options = _ . extend ( {
47
- xMargin : 40 ,
54
+
55
+ // RewardDialog options
56
+ phetGirlScale : 0.6 ,
57
+ scoreDisplayOptions : null , // {Object|null} options passed to ScoreDisplayNumberAndStar
58
+ buttonsFont : DEFAULT_BUTTONS_FONT ,
59
+ buttonsWidth : 110 , // {number} fixed width for both buttons
60
+ buttonsYSpacing : 15 ,
48
61
keepGoingButtonListener : function ( ) { } , // called when 'Keep Going' button is pressed
49
- newLevelButtonListener : function ( ) { } // called when 'New Level' button is pressed
62
+ newLevelButtonListener : function ( ) { } , // called when 'New Level' button is pressed
63
+
64
+ // Dialog options
65
+ xMargin : 30 ,
66
+ yMargin : 20
50
67
} , options ) ;
51
68
52
- var phetGirlNode = new Image ( phetGirlJugglingStarsImage ) ;
53
-
54
- var scoreDisplay = new ScoreDisplayNumberAndStar ( new NumberProperty ( score ) , {
55
- font : SCORE_FONT ,
56
- spacing : 6 ,
57
- starNodeOptions : {
58
- outerRadius : 25 ,
59
- innerRadius : 12.5 ,
60
- filledLineWidth : 3 ,
61
- emptyLineWidth : 3
62
- }
69
+ options . scoreDisplayOptions = _ . extend ( { } , DEFAULT_SCORE_DISPLAY_OPTIONS , options . numeratorOptions ) ;
70
+
71
+ var phetGirlNode = new Image ( phetGirlJugglingStarsImage , {
72
+ scale : options . phetGirlScale
63
73
} ) ;
64
74
75
+ var scoreDisplay = new ScoreDisplayNumberAndStar ( new NumberProperty ( score ) , options . scoreDisplayOptions ) ;
76
+
65
77
var buttonOptions = {
66
- minWidth : 145 , // determined empirically
67
- maxWidth : 145
78
+ font : options . buttonsFont ,
79
+ minWidth : options . buttonsWidth ,
80
+ maxWidth : options . buttonsWidth
68
81
} ;
69
82
70
83
var keepGoingButton = new RectangularPushButton ( _ . extend ( { } , buttonOptions , {
71
- content : new Text ( keepGoingString , { font : BUTTON_FONT } ) ,
84
+ content : new Text ( keepGoingString , { font : DEFAULT_BUTTONS_FONT } ) ,
72
85
listener : options . keepGoingButtonListener ,
73
86
baseColor : 'white'
74
87
} ) ) ;
75
88
76
89
var newLevelButton = new RectangularPushButton ( _ . extend ( { } , buttonOptions , {
77
- content : new Text ( newLevelString , { font : BUTTON_FONT } ) ,
90
+ content : new Text ( newLevelString , { font : DEFAULT_BUTTONS_FONT } ) ,
78
91
listener : options . newLevelButtonListener ,
79
92
baseColor : PhetColorScheme . PHET_LOGO_YELLOW
80
93
} ) ) ;
81
94
95
+ var buttons = new VBox ( {
96
+ children : [ keepGoingButton , newLevelButton ] ,
97
+ spacing : options . buttonsYSpacing
98
+ } ) ;
99
+
100
+ // half the remaining height, so that scoreDisplay will be centered in the negative space above the buttons.
101
+ var scoreSpacing = ( phetGirlNode . height - scoreDisplay . height - buttons . height ) / 2 ;
102
+ assert && assert ( scoreSpacing > 0 , 'phetGirlNode is scaled down too much' ) ;
103
+
82
104
var rightSideNode = new VBox ( {
83
- children : [ scoreDisplay , new VStrut ( 20 ) , keepGoingButton , newLevelButton ] ,
84
- spacing : 25
105
+ children : [ scoreDisplay , buttons ] ,
106
+ align : 'center' ,
107
+ spacing : scoreSpacing
85
108
} ) ;
86
109
87
110
var content = new HBox ( {
111
+ align : 'bottom' ,
88
112
children : [ phetGirlNode , rightSideNode ] ,
89
113
spacing : 40
90
114
} ) ;
0 commit comments