phetsims / build-an-atom

"Build an Atom" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/build-an-atom
GNU General Public License v3.0
11 stars 10 forks source link

Game timer does not run off of joist time #161

Closed samreid closed 7 years ago

samreid commented 7 years ago

While working on https://github.com/phetsims/joist/issues/423 I found that pausing the sim using Sim.activeProperty does not pause the game timer. This is because the game timer is implemented like so:

      this.gameTimerId = window.setInterval( function() {
        self.elapsedTimeProperty.set( self.elapsedTimeProperty.get() + 1 );
      }, 1000 );

This will have problems for PhET-iO and Legends of Learning (non-PhET-iO). One solution may be to switch to phet-core Timer, but perhaps the best solution would be to pass through dt values through step().

@jbphet can you please look into this?

jbphet commented 7 years ago

I went ahead and moved the advancement of the timer into the step function. I've tested it out, and it appears to work well and is consistent with the operation of the currently published version.

I also tested it in the "instance proxies" wrapper to verify that that game clock now stops when buildAnAtom.sim.activeProperty is set to false, and it does.

@samreid - please review and close if it looks like this should do the trick.

jessegreenberg commented 7 years ago

This is working great in the legends of learning test harness, and I also verified that the timer is working in the instance-proxies wrapper. Thanks @jbphet, closing.