-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScene_Title.js
112 lines (95 loc) · 3.41 KB
/
Scene_Title.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//-----------------------------------------------------------------------------
// Scene_Title
//
// The scene class of the title screen.
function Scene_Title() {
this.initialize.apply(this, arguments);
}
Scene_Title.prototype = Object.create(Scene_Base.prototype);
Scene_Title.prototype.constructor = Scene_Title;
Scene_Title.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
Scene_Title.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.createBackground();
this.createForeground();
this.createWindowLayer();
this.createCommandWindow();
};
Scene_Title.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SceneManager.clearStack();
this.centerSprite(this._backSprite1);
this.centerSprite(this._backSprite2);
this.playTitleMusic();
this.startFadeIn(this.fadeSpeed(), false);
};
Scene_Title.prototype.update = function() {
if (!this.isBusy()) {
this._commandWindow.open();
}
Scene_Base.prototype.update.call(this);
};
Scene_Title.prototype.isBusy = function() {
return this._commandWindow.isClosing() || Scene_Base.prototype.isBusy.call(this);
};
Scene_Title.prototype.terminate = function() {
Scene_Base.prototype.terminate.call(this);
SceneManager.snapForBackground();
};
Scene_Title.prototype.createBackground = function() {
this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
this.addChild(this._backSprite1);
this.addChild(this._backSprite2);
};
Scene_Title.prototype.createForeground = function() {
this._gameTitleSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
this.addChild(this._gameTitleSprite);
if ($dataSystem.optDrawTitle) {
this.drawGameTitle();
}
};
Scene_Title.prototype.drawGameTitle = function() {
var x = 20;
var y = Graphics.height / 4;
var maxWidth = Graphics.width - x * 2;
var text = $dataSystem.gameTitle;
this._gameTitleSprite.bitmap.outlineColor = 'black';
this._gameTitleSprite.bitmap.outlineWidth = 8;
this._gameTitleSprite.bitmap.fontSize = 72;
this._gameTitleSprite.bitmap.drawText(text, x, y, maxWidth, 48, 'center');
};
Scene_Title.prototype.centerSprite = function(sprite) {
sprite.x = Graphics.width / 2;
sprite.y = Graphics.height / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
};
Scene_Title.prototype.createCommandWindow = function() {
this._commandWindow = new Window_TitleCommand();
this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this.addWindow(this._commandWindow);
};
Scene_Title.prototype.commandNewGame = function() {
DataManager.setupNewGame();
this._commandWindow.close();
this.fadeOutAll();
SceneManager.goto(Scene_Map);
};
Scene_Title.prototype.commandContinue = function() {
this._commandWindow.close();
SceneManager.push(Scene_Load);
};
Scene_Title.prototype.commandOptions = function() {
this._commandWindow.close();
SceneManager.push(Scene_Options);
};
Scene_Title.prototype.playTitleMusic = function() {
AudioManager.playBgm($dataSystem.titleBgm);
AudioManager.stopBgs();
AudioManager.stopMe();
};