Skip to content

RewardNode

Overview

Reward node that shows many nodes animating continuously, for fun! Shown when a perfect score is achieved in a game. You can also test this by running vegas/vegas_en.html and clicking on the "Reward" screen. Note that the number of images falling is constant, so if the screen is stretched out vertically (tall thin window) they will be less dense.

There are two ways to run the animation step function. The client code can manually call step(dt), or the client code can pass in an Events instance that triggers events on 'step'. In the latter case, the listener will automatically be removed when the animation is complete.

For details about the development of the RewardNode, please see https://github.com/phetsims/vegas/issues/4

@author Sam Reid (PhET Interactive Simulations)

Class RewardNode

import { RewardNode } from 'scenerystack/sim';

Constructor

new RewardNode( providedOptions? : RewardNodeOptions )

Instance Methods

dispose()

paintCanvas( context : CanvasRenderingContext2D )

Paint the rewards on the canvas.

step( dt : number )

Animates the images.

Static Methods

createRandomNodes( nodes : Node[], count : number ) : Node[]

Convenience factory method to create an array of the specified Nodes in an even distribution.

Type RewardNodeOptions

import type { RewardNodeOptions } from 'scenerystack/sim';
  • nodes?: Node[] | null
    Nodes to appear in the reward node. They will be cached as images to improve performance. If null, then default Nodes will be created.
  • scaleForResolution?: number
    Scale things up for rasterization, then back down for rendering, so they have nice quality on retina displays.
  • stepEmitter?: TReadOnlyEmitter<[ number ]> | null
    If you pass in a stepEmitter {Emitter}, it will drive the animation
  • & CanvasNodeOptions

Source Code

See the source for RewardNode.ts in the vegas repository.