Medal

Medal

Medal Object - Tracks an unlockable medal

Constructor

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

Create an medal object and adds it to the list of medals
Parameters:
Name Type Attributes Default Description
id Number The unique identifier of the medal
name String Name of the medal
description String <optional>
Description of the medal
icon String <optional>
'🏆' Icon for the medal
src String <optional>
Image location for the medal
Example
// 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();

Methods

# render(hidePercentopt)

Render a medal
Parameters:
Name Type Attributes Default Description
hidePercent Number <optional>
0 How much to slide the medal off screen

# renderIcon(x, y, sizeopt)

Render the icon for a medal
Parameters:
Name Type Attributes Default Description
x Number Screen space X position
y Number Screen space Y position
size Number <optional>
medalDisplayIconSize Screen space size

# unlock()

Unlocks a medal if not already unlocked