LittleJS 1.28.0

Medals

Medal

Medal - Tracks an unlockable medal

Extended by NewgroundsMedal, WavedashMedal

Constructor

new Medal(id, name, description, icon, src)medalSystem.js:198

Create a medal and add it to the list of medals

id number

The unique identifier of the medal

name string

Name of the medal

description string optional

Description of the medal

icon string optional, default 🏆

Icon for the medal

src string optional

Image location for the medal

// create a medal
const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');

// initialize medals
medalsInit('Example Game');

// unlock the medal
medal_example.unlock();

Members

Methods

Members

description : stringmedalSystem.js:218

Description of the medal

icon : stringmedalSystem.js:221

Icon for the medal

The unique identifier of the medal

image : HTMLImageElement|undefinedmedalSystem.js:228

Source image for the medal icon, if any

name : stringmedalSystem.js:215

Name of the medal

unlocked : booleanmedalSystem.js:224

Is the medal unlocked?

Methods

isLocal() → booleanmedalSystem.js:254

Whether the local save holds this medal, it is neither loaded nor written while a service like Newgrounds holds it

render(hidePercent)medalSystem.js:259

Render a medal

hidePercent number optional, default 0

How much to slide the medal off screen

renderIcon(pos, size)medalSystem.js:301

Render the icon for a medal

pos Vector2

Screen space position

size number

Screen space size

unlock() → Promise<boolean>medalSystem.js:241

Unlocks a medal if not already unlocked

  • The promise is optional, for when a game wants to know the outcome
Returns
  • Whether the medal is unlocked, right away unless a service like Newgrounds has to confirm