-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameMain.ts
117 lines (96 loc) · 2.86 KB
/
GameMain.ts
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
113
114
115
116
117
namespace Rf.ETS.FrameWork {
/**
* ゲームメイン処理
* @classdesc ゲームメインクラス
* @constructor
* @memberof FrameWork
*/
export class GameMain
{
/**
* リソース管理
*/
protected resourceManager: ResourceManager;
/**
* スクリーンサイズ:幅
*/
protected screenWidth:number = 640;
/**
* スクリーンサイズ:高さ
*/
protected screenHeight:number = 480;
/**
* fps
*/
protected fps:number = 10;
/**
* enchant.Coreインスタンス
*/
protected enchantInstance:enchant.Core;
/**
* コンストラクタ
* @method
* @name FrameWork.GameMain#GameMain
*/
public constructor()
{
this.resourceManager = new ResourceManager();
this.resourceManager.SetResourcePath("assets/resources/");
enchant();
//初期化イベント
this.onInitialize();
//create enchantInstance
this.enchantInstance = new enchant.Core(this.screenWidth,this.screenHeight);
this.enchantInstance.fps = this.fps;
//リソース設定イベント
this.onResourceSetting();
//リソースロード
this.enchantInstance.preload(this.resourceManager.GetResourceNames());
this.enchantInstance.onload = (e)=>{
//Create Stage
let stage = new enchant.Group();
this.enchantInstance.currentScene.addChild(stage);
//ロードイベント
this.onLoad(stage);
//フレーム処理
this.enchantInstance.on(enchant.Event.ENTER_FRAME, () => {
this.onRun();
});
}
this.enchantInstance.start();
}
/**
* 初期化イベント
* @method
* @name FrameWork.GameMain#onInitialize
*/
protected onInitialize():void
{
}
/**
* リソース設定イベント
* @method
* @name FrameWork.GameMain#onResourceSetting
*/
protected onResourceSetting():void
{
}
/**
* ロードイベント
* @method
* @name FrameWork.GameMain#onLoad
* @param {Object} parent - 親Group
*/
protected onLoad(parent: enchant.Group):void
{
}
/**
* 実行イベント
* @method
* @name FrameWork.GameMain#onRun
*/
protected onRun():void
{
}
}
}