Skip to content

Commit 4fb5df2

Browse files
committed
Merge pull request phaserjs#2314 from staff0rd/add_rnd_state
Added RandomDataGenerator.state to typescript definitions
2 parents 5703178 + b904efe commit 4fb5df2

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

typescript/phaser.comments.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20434,7 +20434,7 @@ declare module Phaser {
2043420434
*
2043520435
* @param seeds An array of values to use as the seed, or a generator state (from {#state}).
2043620436
*/
20437-
constructor(seeds: number[]);
20437+
constructor(seeds: number[]|string);
2043820438

2043920439

2044020440
/**
@@ -20512,6 +20512,24 @@ declare module Phaser {
2051220512
*/
2051320513
sow(seeds: number[]): void;
2051420514

20515+
/**
20516+
* Gets or Sets the state of the generator. This allows you to retain the values
20517+
* that the generator is using between games, i.e. in a game save file.
20518+
*
20519+
* To seed this generator with a previously saved state you can pass it as the
20520+
* `seed` value in your game config, or call this method directly after Phaser has booted.
20521+
*
20522+
* Call this method with no parameters to return the current state.
20523+
*
20524+
* If providing a state it should match the same format that this method
20525+
* returns, which is a string with a header `!rnd` followed by the `c`,
20526+
* `s0`, `s1` and `s2` values respectively, each comma-delimited.
20527+
*
20528+
* @param state Generator state to be set.
20529+
* @return The current state of the generator.
20530+
*/
20531+
state(state?: string): string;
20532+
2051520533
/**
2051620534
* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
2051720535
*

typescript/phaser.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3791,7 +3791,7 @@ declare module Phaser {
37913791

37923792
class RandomDataGenerator {
37933793

3794-
constructor(seeds: number[]);
3794+
constructor(seeds: number[]|string);
37953795

37963796
angle(): number;
37973797
between(min: number, max: number): number;
@@ -3803,6 +3803,7 @@ declare module Phaser {
38033803
real(): number;
38043804
realInRange(min: number, max: number): number;
38053805
sow(seeds: number[]): void;
3806+
state(state?: string): string;
38063807
timestamp(min: number, max: number): number;
38073808
uuid(): number;
38083809
weightedPick<T>(ary: T[]): T;

0 commit comments

Comments
 (0)