8 min read
Phaser 3 adapter
Connect Phaser lifecycle, audio, ads, and rewards to D3 SDK v1.
Install and register
Load Phaser first, the core D3 SDK second, and the adapter last. Register it once as a global Phaser plugin.
<script src="phaser.min.js"></script>
<script src="https://cdn.games.devs3.pro/sdk/v1/d3-games-sdk.js"></script>
<script src="https://cdn.games.devs3.pro/sdk/phaser/v1/d3-phaser-adapter.js"></script>
plugins: { global: [{
key: "D3GamesPlugin",
plugin: D3PhaserAdapter.Plugin,
start: true,
data: { gameId: "your-game-slug", autoPause: true }
}] }Lifecycle
- 1.Call loadingFinished after preload and create are genuinely complete.
- 2.Call gameplayStart from the first real player input.
- 3.Call gameplayStop for menus, death, cutscenes, and level completion.
- 4.autoPause handles browser blur/focus and restores only state paused by the adapter.
Ads and rewards
commercialBreak and rewardedBreak sleep the game loop and pause currently-playing sounds until the host result arrives.
const d3 = this.plugins.get("D3GamesPlugin");
const result = await d3.rewardedBreak({
placement: "revive", rewardId: "extra-life"
});
if (result.granted) revivePlayer();Only result.granted === true or d3:reward-granted authorizes a reward.