Medal#

Medal - Tracks an unlockable medal

Constructor#

new Medal(id, name, descriptionopt, iconopt, srcopt)#

Create a medal object and adds it to the list of medals

Parameters:
NameTypeAttributesDefaultDescription
idNumber

The unique identifier of the medal

nameString

Name of the medal

descriptionString<optional>

Description of the medal

iconString<optional>
🏆

Icon for the medal

srcString<optional>

Image location for the medal

Example
CODE
// 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#

description#

Properties
TypeDescription
String

Description of the medal

icon#

Properties
TypeDescription
String

Icon for the medal

id#

Properties
TypeDescription
Number

The unique identifier of the medal

name#

Properties
TypeDescription
String

Name of the medal

unlocked#

Properties
TypeDescription
Boolean

Is the medal unlocked?

Methods#

render(hidePercentopt)#

Render a medal

Parameters:
NameTypeAttributesDefaultDescription
hidePercentNumber<optional>
0

How much to slide the medal off screen

renderIcon(pos, sizeopt)#

Render the icon for a medal

Parameters:
NameTypeAttributesDefaultDescription
posVector2

Screen space position

sizeNumber<optional>
medalDisplayIconSize

Screen space size

unlock()#

Unlocks a medal if not already unlocked