diff --git a/js/ohms-law/view/OhmsLawScreenView.js b/js/ohms-law/view/OhmsLawScreenView.js index d2a5a6a..09805a9 100644 --- a/js/ohms-law/view/OhmsLawScreenView.js +++ b/js/ohms-law/view/OhmsLawScreenView.js @@ -38,6 +38,15 @@ define( function( require ) { ScreenView.call( this ); + // Node of ohm's law equation. Layout is hardwired, see FormulaNode. + var formulaNode = new FormulaNode( model.currentProperty, model.voltageProperty, model.resistanceProperty, { + pickable: false + } ); + + // Add the formula first + this.addChild( formulaNode ); + + // Circuit node with readout node var wireBox = new WireBox( model.voltageProperty, model.resistanceProperty, model.currentProperty, { pickable: false, @@ -46,12 +55,6 @@ define( function( require ) { } ); this.addChild( wireBox ); - // Node of ohm's law equation. Layout is hardwired, see FormulaNode. - var formulaNode = new FormulaNode( model.currentProperty, model.voltageProperty, model.resistanceProperty, { - pickable: false - } ); - this.addChild( formulaNode ); - // Create and add control panel with sliders. var controlPanel = new ControlPanel( model.voltageProperty, model.resistanceProperty ); controlPanel.right = this.layoutBounds.width - 25; // empirically determined diff --git a/js/ohms-law/view/RightAngleArrow.js b/js/ohms-law/view/RightAngleArrow.js index eb2b15a..c78abd6 100644 --- a/js/ohms-law/view/RightAngleArrow.js +++ b/js/ohms-law/view/RightAngleArrow.js @@ -13,7 +13,6 @@ define( function( require ) { // modules var inherit = require( 'PHET_CORE/inherit' ); var Matrix3 = require( 'DOT/Matrix3' ); - var Node = require( 'SCENERY/nodes/Node' ); var Path = require( 'SCENERY/nodes/Path' ); var PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' ); var Shape = require( 'KITE/Shape' ); @@ -40,25 +39,27 @@ define( function( require ) { * @constructor */ function RightAngleArrow( currentProperty, options ) { - - Node.call( this ); + var self = this; // create the shape of the arrow var arrowShape = new Shape().polygon( POINTS ); - var arrowPath = new Path( arrowShape, { + + Path.call( this, arrowShape, { stroke: '#000', fill: PhetColorScheme.RED_COLORBLIND, lineWidth: 0.2 } ); - this.addChild( arrowPath ); // Present for the lifetime of the simulation - currentProperty.link( function( current ) { + currentProperty.lazyLink( function( current) { // Scale the arrows based on the value of the current. // Exponential scaling algorithm. Linear makes the changes too big. var scale = Math.pow( ( current * 0.1 ), 0.7 ); - arrowPath.matrix = Matrix3.scale( scale ); + + // TODO: use scale instead of overwriting the matrix each time the current changes + self.matrix = Matrix3.scale( scale ); + self.mutate( options ); } ); this.mutate( options ); @@ -66,5 +67,5 @@ define( function( require ) { ohmsLaw.register( 'RightAngleArrow', RightAngleArrow ); - return inherit( Node, RightAngleArrow ); + return inherit( Path, RightAngleArrow ); } );