This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instructions.js
54 lines (49 loc) · 2.37 KB
/
instructions.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
50
51
52
53
54
class Instructions extends Phaser.Scene
{
init (data)
{
this.titleName = data.titleName;
this.description = data.description;
this.stickersAtOnce = data.stickersAtOnce;
this.totalLaptopsToGet = data.totalLaptopsToGet;
this.countdownSeconds = data.countdownSeconds;
this.modeSelect = data.modeSelect;
}
create ()
{
//Notepad for title and description
var notepad = this.add.sprite(0, 0, 'pad').setOrigin(0, 0);
notepad.setScale(1.5, 1.1);
notepad.setSize(notepad.width*notepad.scaleX, notepad.height*notepad.scaleY);
notepad.setPosition((config.width/2) - (notepad.width/2), ((config.height/8)*3) - (notepad.height/2));
//Title
var title = this.add.text(0, 0, this.titleName,
{fontFamily: "Indie Flower, Arial, Carrois Gothic SC", fontSize: '30px', fill: '#000', fontStyle: 'bold'});
title.setPosition(notepad.x + ((notepad.width/2) - Math.floor(title.width/2)), Math.floor(notepad.y + 5));
//Description
var desc = this.add.text(Math.floor(notepad.x + 10), Math.floor(notepad.y + ((notepad.height/10)*3) - 10),
this.description, {fontFamily: "Indie Flower, Arial, Carrois Gothic SC", fontSize: '22px', fill: '#000' });
//Button to start game
var playPostItNote = this.add.sprite(0, 0, 'note').setOrigin(0, 0);
playPostItNote.setPosition((config.width/2) - (playPostItNote.width/2), (config.height/2)+75);
const playButton = this.add.text(0, 0, 'Play',
{fontFamily: "Indie Flower, Arial, Carrois Gothic SC", fontSize: '24px', fill: '#000' })
.setInteractive()
.on('pointerdown', (pointer)=> {
if(pointer.leftButtonDown())
{
playButton.setStyle({ fill: '#404'});
this.sound.play('gong');
this.scene.start('mainGame', { stickersAtOnce: this.stickersAtOnce, totalLaptopsToGet: this.totalLaptopsToGet, countdownSeconds: this.countdownSeconds, modeSelect: this.modeSelect});
this.scene.stop('mainMenu');
this.scene.stop();
}
})
.on('pointerover', () => {
this.sound.play('hover');
playButton.setStyle({ fill: '#808'});
})
.on('pointerout', () => playButton.setStyle({ fill: '#000' }) );
playButton.setPosition(Math.floor(playPostItNote.x + ((playPostItNote.width/2)-(playButton.width/2))), Math.floor(playPostItNote.y + (playPostItNote.height/2)));
}
}