Skip to content

NewgroundsJS

Defined in: newgrounds.d.ts:415

autoPing(ms): void

Defined in: newgrounds.d.ts:508

Automatically pings the Newgrounds API, this is useful for keeping the session alive

Parameter Type Description
ms number The interval in milliseconds

void


connect(appID, encKey, config?): NewgroundsClient

Defined in: newgrounds.d.ts:424

Create a client and connect to the Newgrounds API

Parameter Type Description
appID string The app id found on the Newgrounds API project page
encKey string The encryption key found on the Newgrounds API project page
config? NewgroundsConfig -

NewgroundsClient

A new NewgroundsClient


getCloudData(id): Promise<string>

Defined in: newgrounds.d.ts:481

Get cloud data from a save slot

Parameter Type Description
id number The id of the save slot

Promise<string>

The data stored in the save slot


getScores(scoreboardID, opt): Promise<Score[]>

Defined in: newgrounds.d.ts:446

Get the scores for a scoreboard

Parameter Type Description
scoreboardID number The id of the scoreboard to get scores from
opt ScoreBoardGetScoresParams -

Promise<Score[]>

Scores corresponding to the scoreboard


getUsername(): Promise<string | undefined>

Defined in: newgrounds.d.ts:461

Get the username of the current user

Promise<string | undefined>

The username of the current user, if they are logged in


getVersion(): Promise<string>

Defined in: newgrounds.d.ts:467

Get the version of your Newgrounds Project

Promise<string>

The version of your Newgrounds Project


isOnNewgrounds(): boolean

Defined in: newgrounds.d.ts:496

Check if the game is current running on Newgrounds.com

boolean

A boolean indicating if the game is running on Newgrounds.com


isSupporter(): Promise<boolean | undefined>

Defined in: newgrounds.d.ts:473

Check if the current user is a supporter

Promise<boolean | undefined>

A boolean indicating if the user is a supporter, if they are logged in


loadSoundID(id): Promise<ArrayBuffer>

Defined in: newgrounds.d.ts:515

A function to load a sound as a ArrayBuffer based on the provided ID.

Parameter Type Description
id string | number The ID of the sound to load.

Promise<ArrayBuffer>

A promise that resolves with the loaded sound as an ArrayBuffer.


login(): Promise<User>

Defined in: newgrounds.d.ts:430

Log in the user

Promise<User>

The user that was logged in


ping(): Promise<string>

Defined in: newgrounds.d.ts:502

Pings the Newgrounds API

Promise<string>

“pong”


postScore(scoreboardID, value): Promise<Score>

Defined in: newgrounds.d.ts:455

Post a score to a scoreboard

Parameter Type Description
scoreboardID number The id of the scoreboard to post the score to
value number The value of the score

Promise<Score>

The Score that was posted to the board.


setCloudData(id, value): Promise<SaveSlot>

Defined in: newgrounds.d.ts:490

Set cloud data in a save slot

Parameter Type Description
id number The id of the save slot
value string The value to store in the save slot

Promise<SaveSlot>

The save slot that was updated


unlockMedal(medalID): Promise<boolean>

Defined in: newgrounds.d.ts:438

Unlock a medal

Parameter Type Description
medalID number The id of the medal to unlock

Promise<boolean>

A boolean indicating if the medal was unlocked

Property Type Description Defined in
NewgroundsClient typeof NewgroundsClient The NewgroundsClient class newgrounds.d.ts:519