Skip to content

Screen

Overview

A Screen is the largest chunk of a simulation. (Java sims used the term Module, but that term is too overloaded to use with JavaScript and Git.)

When creating a Sim, Screens are supplied as the arguments. They can be specified as object literals or through instances of this class. This class may centralize default behavior or state for Screens in the future, but right now it only allows you to create Sims without using named parameter object literals.

@author Sam Reid (PhET Interactive Simulations)

Class Screen

Parameterized on M=Model and V=View

import { Screen } from 'scenerystack/sim';

Constructor

new Screen( createModel : () => M, createView : ( model: M ) => V, providedOptions : ScreenOptions )

Instance Methods

hasModel() : boolean

hasView() : boolean

reset()

Instance Properties

backgroundColorProperty : Property<Color> | Property<string> | Property<Color | string>

maxDT : number

(readonly)

dt cap in seconds, see https://github.com/phetsims/joist/issues/130

activeProperty : BooleanProperty

(readonly)

screenButtonsHelpText : PDOMValueType

(readonly)

Help text used on the screen buttons, see options above.

nameProperty : TReadOnlyProperty<string>

(readonly)

showScreenIconFrameForNavigationBarFill : string | null

(readonly)

homeScreenIcon : ScreenIcon | null

(readonly)

showUnselectedHomeScreenIconFrame : boolean

(readonly)

createKeyboardHelpNode : null | ( ( tandem: Tandem ) => Node )

(readonly)

pdomDisplayNameProperty : TReadOnlyProperty<string>

(readonly)

Static Properties

HOME_SCREEN_ICON_ASPECT_RATIO

(readonly)

MINIMUM_HOME_SCREEN_ICON_SIZE

(readonly)

MINIMUM_NAVBAR_ICON_SIZE

(readonly)

ScreenIO : IOType

(readonly)

Type ScreenOptions

import type { ScreenOptions } from 'scenerystack/sim';
  • name?: PhetioProperty<string> | null
  • instrumentNameProperty?: boolean
  • backgroundColorProperty?: Property<Color | string> | Property<Color> | Property<string> | ProfileColorProperty
    It would be preferable to support Property<Color | string> solely, but many subtypes are hardcoded to be Color only or string only, so we support this polymorphic form
  • homeScreenIcon?: ScreenIcon | null
  • showUnselectedHomeScreenIconFrame?: boolean
  • navigationBarIcon?: ScreenIcon | null
  • showScreenIconFrameForNavigationBarFill?: string | null
  • maxDT?: number
    dt cap in seconds, see https://github.com/phetsims/joist/issues/130
  • createKeyboardHelpNode?: null | ( ( tandem: Tandem ) => Node )
  • screenButtonsHelpText?: PDOMValueType | null
    Help text that will be added to the Home screen button and navigation bar button for this screen. This is often a full but short sentence with a period at the end of it. This is also used as the hint response for these buttons with the Voicing feature.
  • & StrictOmit<PhetioObjectOptions, "tandemNameSuffix"> & PickRequired<PhetioObjectOptions, "tandem">

Source Code

See the source for Screen.ts in the joist repository.