Achievements

Achievements in HTML5 games are an exciting and rewarding feature that adds an extra layer of engagement for players. They serve as milestones, celebrating a player's progress, skill, and dedication.

Support

Use this to determine if you can implement achievements for your game on the current platform.

bridge.achievements.is_supported()

Check if getting list of achievements is supported.

bridge.achievements.is_get_list_supported()

Check if built-in popup is supported.

bridge.achievements.is_native_popup_supported()

Unlock achievement

Unlocks achievement for a player.

local bridge = require("bridge.bridge")

function init(self)
    local options = {
        y8 = {
            achievement = "ACHIEVEMENT_NAME",
            achievementkey = "ACHIEVEMENT_KEY"
        },
        lagged = {
            achievement = "ACHIEVEMENT_ID"
        }
    }

    bridge.achievements.unlock(options, function ()
        -- success
    end, function ()
        -- error
    end)
end

Get List

Returns the achievements list

local bridge = require("bridge.bridge")

function init(self)
    local options = { }
    bridge.achievements.get_list(options, function (_, data)
        -- success
    end, function ()
        -- error
    end)
end

Show Native Popup

Some platforms support built-in achievement list which is shown in overlay

local bridge = require("bridge.bridge")

function init(self)
    local options = { }
    bridge.achievements.show_native_popup(options, function ()
        -- success
    end, function ()
        -- error
    end)
end

Last updated