SDK
API reference
Every call on the VPlay object. None of them throw: each resolves with a safe default.
| Call | What it does |
|---|---|
init({ gameId, hostOrigins?, openUrl?, autoTheme? }) | Connects. Returns the player, items, save and platform description. Never throws. |
loading(progress) | 0 to 1 while assets load. |
gameplayStart() / gameplayStop() | Tell VPlay when the player is actually playing (a run opens on our server) and when a menu, pause or shop is up. |
score(n) / lives(n) / level(n) | Live hints, for display only. They are never used as your result. |
gameOver({ score, level?, reason? }) | Reports a finished run. Resolves { accepted, flagged, best }. The server decides; a flagged run is never ranked or rewarded. |
win({ score, level? }) | Same as gameOver, marked as a win. |
purchase(itemId) | Asks to unlock an item. VPlay shows its own confirm sheet. Resolves purchased, cancelled, needs_signin, insufficient, unavailable or error. |
entitlements() | Resolves the item ids the player owns. |
milestone(id) | Reports one-time progress. The reward is whatever we registered for that id; reporting twice does nothing. |
saveCloud(data) | Saves JSON up to 64 KB for the player. Writes are combined for you; call flush() to write immediately. |
flush() | Writes a pending cloud save now (for example when the player leaves). |
ads.available(type) / ads.show({ type, placement? }) | Ad breaks (interstitial or rewarded). VPlay shows its own ad and pauses your game. Resolves { status, rewarded }; never rejects. |
showLeaderboard() | Opens VPlay's own leaderboard over your game and pauses it. Your game receives nothing. |
leaderboard({ scope?, limit? }) | Returns the board as data, for a game that draws its own (a capability we switch on per game). Scopes: all, week, day, tournament. Resolves null when unavailable. |
feature(name) | True if a platform feature is on right now: purchases, milestones, saves, leaderboard, tournaments, ads. |
has(capability) | True if your game has been granted a capability (for example leaderboard data). |
host, theme, tournament | Read the live platform description, colours and the running tournament (or null). |
applyTheme(el?) | Writes the colours into CSS variables. Done for you unless you pass autoTheme: false. |
on(event, fn) | Subscribes to an event. Returns a function that unsubscribes. |
openOnVplay() | Standalone only: opens your game's page on VPlay. |
destroy() | Disconnects and removes the SDK's listeners. |
