Skip to content

Commit

Permalink
convert to TypeScript, #80
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 2, 2023
1 parent 255a72e commit 6bed9cb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions js/game/view/GameScreenView.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Copyright 2014-2023, University of Colorado Boulder

// @ts-nocheck
/**
* View for the 'Game' screen.
*
* @author Chris Malley (PixelZoom, Inc.)
*/

import ScreenView from '../../../../joist/js/ScreenView.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import GameAudioPlayer from '../../../../vegas/js/GameAudioPlayer.js';
import RPALConstants from '../../common/RPALConstants.js';
import reactantsProductsAndLeftovers from '../../reactantsProductsAndLeftovers.js';
import GameModel from '../model/GameModel.js';
import GamePhase from '../model/GamePhase.js';
import PlayNode from './PlayNode.js';
import ResultsNode from './ResultsNode.js';
import SettingsNode from './SettingsNode.js';

export default class GameScreenView extends ScreenView {

/**
* @param {GameModel} model
* @param {Tandem} tandem
*/
constructor( model, tandem ) {
private playNode: PlayNode | null; // created on demand
private resultsNode: ResultsNode | null; // created on demand

public constructor( model: GameModel, tandem: Tandem ) {

super( {
layoutBounds: RPALConstants.SCREEN_VIEW_LAYOUT_BOUNDS,
Expand All @@ -33,9 +33,9 @@ export default class GameScreenView extends ScreenView {
const audioPlayer = new GameAudioPlayer();

// one node for each 'phase' of the game, created on demand to improve startup time
let settingsNode = null; // @private
this.playNode = null; // @private
this.resultsNode = null; // @private
let settingsNode: SettingsNode | null = null;
this.playNode = null;
this.resultsNode = null;

/*
* Handle game 'phase' changes, nodes created on demand to reduce startup time.
Expand Down Expand Up @@ -68,20 +68,21 @@ export default class GameScreenView extends ScreenView {

/**
* Animation step function.
* @param {number} elapsedTime time between step calls, in seconds
* @public
* @param dt - time between step calls, in seconds
*/
step( elapsedTime ) {
public override step( dt: number ): void {

// animate the reward
if ( this.resultsNode && this.resultsNode.visible ) {
this.resultsNode.step( elapsedTime );
this.resultsNode.step( dt );
}

// cleanup nodes
if ( this.playNode ) {
this.playNode.step( elapsedTime );
this.playNode.step( dt );
}

super.step( dt );
}
}

Expand Down

0 comments on commit 6bed9cb

Please sign in to comment.