<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta charset="UTF-8">
<title>HTML5Test</title>
-
+<style type="text/css">
+ h1, h2, h3 {
+ margin:0px;
+ }
+ body, textarea {
+ font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+ font-size: 11px;
+ line-height: 1.2;
+ }
+</style>
<script type="text/javascript" src="./corelib/header.js" charset="UTF-8"></script>
<script type="text/javascript">
var mainManager = null;
-var run = function() {
+var dbg = null;
+onload = function()
+{
+ var val = localStorage.getItem("savedat");
+ if(val)
+ {
+ document.getElementById("stageCode").value = val;
+ }
+
//ゲームマネージャー初期化
- mainManager = new GameManager();
- var stage = document.getElementById("stageCode").value;
- mainManager.loadStageFromLocal(stage, null);
-}
+ //mainManager = new GameManager();
+ mainManager = document.getElementById('MainArea').InitGameManager();
+ dbg = mainManager.debugText;
+ //最初はグローバルデバッグモードはオフ
+ mainManager.debugText = null;
+
+ //コールバック指定
+ mainManager.stageStartedEvent = function(stage)
+ {
+ document.getElementById('MainArea').style.visibility = 'visible';
+ };
+ mainManager.stageStoppedEvent = function(stage)
+ {
+ document.getElementById('MainArea').style.visibility = 'hidden';
+ };
+
+ var prev;
+ if(prev = localStorage.getItem("previewStage"))
+ {
+ localStorage.removeItem("previewStage");
+ document.getElementById('stageCode').value = (prev);
+ run();
+ }else
+ {
+ location.href="editor/index.html";
+ }
+
+};
-</script>
-</head>
-<body>
- <div id="MainArea" style="position: inline"></div>
- <div id="Resources"></div>
- <div style="z-index: 1; top: 520px; position: absolute; left: 0;">
- <form><textarea id="DebugText" rows="8" cols="64"></textarea></form></div>
- <div style="position: absolute; left: 650px; top: 0; right: 0; z-index: 1">
- <form>
- <textarea id="stageCode" rows="60" style="width: 100%; height: 90%">
-
-//ステージの設定
-// グローバル名前空間にmainManagerがすでに存在する状況下で呼ばれる。
-// 最初の行で新たなインスタンスを生成し、最後のreturnでそれを返す。
+var run = function(){
-stage = new GameStage();
+ var stage = document.getElementById("stageCode").value;
+ mainManager.loadStageFromLocal(stage);
+};
-stage.moveForce = 50;
+function stop(){
+ mainManager.stopStage();
+}
-//関数のオーバーライド
-stage.runStage = function(){
- //元々定義されていた、疑似スーパークラス(prototype)の関数を呼び出す。
- GameStage.prototype.runStage.apply(this, []);
- for(i = 0; i < 2; i++){
- aCircle = new CharacterClass(this);
- aCircle.origin.x = 16 + 16 * i;
- aCircle.origin.y = 16 + 16 * i;
- aCircle.frame.origin.x = - (8 + i);
- aCircle.frame.origin.y = - (8 + i);
- aCircle.frame.size.x = 2 * (8 + i);
- aCircle.frame.size.y = 2 * (8 + i);
-
- this.addStageObject(aCircle);
+function switchDebug()
+{
+ if(mainManager.debugText == null)
+ {
+ mainManager.debugText = dbg;
+ mainManager.runningStage.debugMode = true;
+ mainManager.debugOut("Debug enabled.\n");
+ } else{
+ mainManager.debugOut("Debug disabled.\n");
+ mainManager.debugText = null;
+ mainManager.runningStage.debugMode = false
}
}
-stage.timerTick = function(){
- GameStage.prototype.timerTick.apply(stage, []);
- if(this.manager.keyState.upArrow){
- //上カーソル
- for(i = 0; i < this.stageObjectList.length; i++){
- this.stageObjectList[i].movingSpeed.y -= this.moveForce;
- }
- }
- if(this.manager.keyState.downArrow){
- //下カーソル
- for(i = 0; i < this.stageObjectList.length; i++){
- this.stageObjectList[i].movingSpeed.y += this.moveForce;
- }
- }
- if(this.manager.keyState.leftArrow){
- //左カーソル
- for(i = 0; i < this.stageObjectList.length; i++){
- this.stageObjectList[i].movingSpeed.x -= this.moveForce;
- }
- }
- if(this.manager.keyState.rightArrow){
- //右カーソル
- for(i = 0; i < this.stageObjectList.length; i++){
- this.stageObjectList[i].movingSpeed.x += this.moveForce;
- }
- }
-};
-
-stage;
+function reload()
+{
+ localStorage.setItem("previewStage", document.getElementById('stageCode').value);
+ location.reload();
+}
-
- </textarea>
- <input type="button" onclick="run(); return false;" value="run">
- </form>
+</script>
+</head>
+<body>
+ <div id="MainArea" style="width: 640px; height: 480px; visibility: hidden"></div>
+ <div id="Resources"></div>
+ <div style="z-index: 1;">
+ <form><textarea id="DebugText" rows="8" cols="64"></textarea></form>
+ <input type="button" onclick="run(); return false;" value="ステージの実行/再実行"><input type="button" onclick="stop(); return false;" value="ステージの停止"><input type="button" onclick="switchDebug(); return false;" value="デバッグの有効/無効"><input type="button" onclick="reload(); return false;" value="ページの再読み込み">
</div>
+ <div style="display: none;"><form><textarea id="stageCode"></textarea></form></div>
</body>
</html>
\ No newline at end of file