-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.js
49 lines (43 loc) · 1.51 KB
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Phaser from 'phaser'
export default class MenuScene extends Phaser.Scene {
create () {
this.playButton = this.add.text(640, 460, 'Start!', {
font: '48px Impact',
fill: 'black'
})
this.playButton.setInteractive({ useHandCursor: true })
this.playButton.addListener('pointerdown', () => {
this.scene.start('PlayScene')
})
this.rewardButton = this.add.text(340, 560, 'Watch an AD for coins!!', {
font: '48px Impact',
fill: 'lightgrey'
})
const poki = this.plugins.get('poki')
// Run the following code when the PokiSDK has been initialized, we need this
// to determine if the player has an adblocker installed. When the PokiSDK
// was already initialized the callback is ran immediately.
poki.runWhenInitialized((poki) => {
console.log('PokiSDK has been initialized')
if (poki.hasAdblock) {
this.add.text(10, 10, 'Adblock detected!', {
fill: 'black'
})
}
if (!poki.hasAdblock) {
// When ads are available: enable the rewarded ad button:
this.rewardButton.setTint(0x000000)
this.rewardButton.setInteractive({ useHandCursor: true })
this.rewardButton.addListener('pointerdown', () => {
// This function will mute and disable keyboard input for you
poki.rewardedBreak().then((success) => {
console.log('should rewards?', success)
if (success) {
// Give coins!
}
})
})
}
})
}
}