OSDN Git Service

微調整完了!もう
[h58pcdgame/GameScriptCoreLibrary.git] / www / index_local_debug.html
index 03b448a..e7a4092 100644 (file)
@@ -18,6 +18,7 @@
 <script type="text/javascript">
 
 var mainManager = null;
+var dbg = null;
 onload = function()
 {
        var val = localStorage.getItem("savedat");
@@ -27,7 +28,32 @@ onload = function()
        }
        
        //ゲームマネージャー初期化
-       mainManager = new GameManager();
+       //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";
+       }
        
 };
 
@@ -41,113 +67,35 @@ function stop(){
        mainManager.stopStage();
 }
 
-function save()
+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
+       }
+}
+
+function reload()
 {
-       localStorage.setItem('savedat', document.getElementById('stageCode').value);
+       localStorage.setItem("previewStage", document.getElementById('stageCode').value);
+       location.reload();
 }
 
 </script>
 </head>
 <body>
-       <div id="MainArea" style="position: inline"></div>
+       <div id="MainArea" style="width: 640px; height: 480px; visibility: hidden"></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: 100">
-               <form>
-               <textarea id="stageCode" rows="60" style="width: 100%; height: 90%; z-index: 100">
-
-
-// StageObjectsはステージに文字シンボルとして配置したいオブジェクト定義の連想配列である。
-// StageObjectの各項目の指定方法は以下の二通りある。
-// ・クラス名指定 ... コンストラクタがに引数が不要な時
-// a : BlockClass
-// ・拡張指定
-// a : {base : FreeItemClass,                  //鋳型となるクラス名
-//      args : '1190.png',                             //コンストラクタに指定する引数(一つだけの場合) stageは自動で指定されるので不要
-//      args : ['1190.png', callback], //二つ以上の場合。やはり第一引数のstageは不要
-//      prop : {times : 1},                            //各インスタンスに指定したいプロパティの連想配列。(省略可)
-                                                                               //この例ではaFreeItemClass.timesプロパティを1に指定している
-//      adjust : [-50, 50],                            //位置の微調整。必ずX座標、Y座標の相対位置を示す配列にする。(省略可)
-//      extid : 19                                             //ネットワークを超えて一つのオブジェクトである必要がある場合にはゼロではない値を取る(ステージ内で固有の値, 省略可; 既定0)
-//             sync : true                                             //ネットワーク同期を有効に(addStageObjectの第二引数)(省略可; 既定false)
-
-var stgObjects = {
-       
-       // BlockClass : 普通のブロック。 引数に画像名を指定
-    a : {base:BlockClass,args:'1190.png'},
-    
-    // SlopeBlockClass : 当たり判定が斜めのブロック。
-    // 引数 : 画像名, 当たり判定領域左側の開始位置のブロック上辺からの高さ, 当たり判定領域右側の...
-    //        たとえば、この例のように 0, 32 と指定すれば右下がりの坂になり、32, 0と指定すれば左下がり、 16, 16と指定すれば半分の高さの長方形になる
-    // enableBlockMode : 当たり判定領域をデバッグ表示する。
-    b : {base:SlopeBlockClass,args:['1191.png',0,32],prop:{enableDebugMode:true}},
-    
-    // FreeItemClass : キャラが取得するとコールバックが実行されるアイテム
-    // callback : 誰かに取得されたときに発生するコールバック。アタックした人、そのアタック直後のx, y座標が引数にセットされる。
-    // times : 取得できる回数で、-1で無限。
-    c : {base:FreeItemClass,args:["1234.png",callBack],prop:{times:1}},
-    
-    // 何もブロックを置かない位置のためにかならずこのようなエントリーを記述
-    _ : null
-};
-
-// FreeItemClassのコールバック
-function callBack(obj, obj_x, obj_y)
-{
-       if(obj instanceof MainCharacterClass){
-
-       }
-}
-
-var stgInfo = {
-    width: 6400,                               //横サイズ
-    height: 480,                               //縦サイズ
-    background: "back2.png"            //背景画像。横幅は640pxである必要はない。
-};
-
-with(stgObjects) {
-    var tbl = [
-        [],
-        [],
-        [],
-        [],
-        [],
-        [],
-        [],
-        [],
-        [],
-        [],
-        [b],
-        [_,b],
-        [_,_,b],
-        [_,_,_,b,_,_,_,_,_,c],
-        [a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a],
-    ];
-}
-
-//約束事
-var stage = new PCDSLStageClass(stgInfo, tbl);
-
-stage.runStage = function(){
-       PCDSLStageClass.prototype.runStage.apply(this, []);
-       var main = new MainCharacterClass(stage, [["kuma1.png","kuma2.png","kuma3.png", "kuma4.png", "kuma3.png", "kuma2.png"], ["kumaready.png"]]);
-       main.size.x = 64;
-       main.size.y=64;
-       main.origin.x = 50;
-       main.origin.y =0;
-       main.ownerUID = stage.manager.userID;
-       stage.userControlledCharacter = main;
-       stage.addStageObject(main, true);
-},
-
-
-stage;
-
-               </textarea>
-               <input type="button" onclick="run(); return false;" value="run"><input type="button" onclick="stop(); return false;" value="stop"><input type="button" onclick="save(); return false;" value="save"><br>
-               ※すべてのコードを消したうえでセーブし更新すると最初のコードに戻ります。
-               </form>
+       <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