快速接入
从 sandbox 域引入 SDK,游戏可玩后调用 NG.ready(),并使用异步 save/load 完成存档。

<!doctype html>
<html>
<head><meta charset="utf-8"><title>My Game</title></head>
<body>
<canvas id="stage" width="600" height="600"></canvas>
<script src="https://sandbox.newgame.win/sdk/ng.js"></script>
<script>
const high = await NG.load('high_score') || 0
function onGameOver(score) {
NG.score(score, { level: 4 })
if (score > high) NG.save('high_score', score)
}
NG.ready()
</script>
</body>
</html>核心方法
| 方法 | 用途 |
|---|---|
| NG.ready() | 通知平台隐藏加载界面。 |
| NG.progress(value) | 上报 0 到 1 的加载进度。 |
| NG.score(score, payload?) | 提交排行榜分数。 |
| NG.save(key, value) | 为匿名或登录玩家持久化 JSON 数据。 |
| NG.load(key) | 读取存档值,未命中返回 null。 |
| NG.delete(key) | 删除一条存档。 |
| NG.balance / earn / spend | 为登录玩家使用平台钱包 API。 |