From 4ea64fae1777a345a81ebfb6f07234560c37a81a Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Fri, 6 Mar 2015 22:35:36 -0700 Subject: [PATCH] Added togetherState API, see #208 and https://github.com/phetsims/concentration/issues/34 --- js/Sim.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/Sim.js b/js/Sim.js index 4fefccd9..d862357f 100644 --- a/js/Sim.js +++ b/js/Sim.js @@ -894,7 +894,17 @@ define( function( require ) { }, getStateJSON: function() { - return JSON.stringify( this.getState(), SimJSON.replacer ); + return JSON.stringify( this.getState(), SimJSON.replacer, 2 ); + }, + + // Assuming that together.js API features are enabled, return the state for this screen + get togetherState() { + return JSON.stringify( phet.together.getState( this ), SimJSON.replacer, 2 ); + }, + + set togetherState( stateString ) { + var state = JSON.parse( stateString, SimJSON.reviver ); + phet.together.setState( this, state ); }, getScreenshotDataURL: function() {