OSDN Git Service

ステージ開始時、終了時のコールバックを取れるようにした
authorttwilb <ttwilb@users.sourceforge.jp>
Mon, 26 Aug 2013 14:04:55 +0000 (23:04 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Mon, 26 Aug 2013 14:04:55 +0000 (23:04 +0900)
www/corelib/core.js
www/index_local_debug.html

index 8da1ab4..cc970ce 100644 (file)
@@ -118,6 +118,10 @@ function GameManager(parent, debugTextName){
        //timerTick
        timerTickEventListener.manager = this;
        window.setInterval(timerTickEventListener, 1000/this.tickPerSecond);
+       
+       //各種コールバック(使用元のスクリプトで使う用)
+       this.stageStartedEvent = null;          //ステージが開始されたときに呼ばれる。引数: stage
+       this.stageStoppedEvent = null;          //ステージが終了されたときに呼ばれる。引数: stage
 }
 GameManager.prototype = {
        timerTick: function(){
@@ -201,6 +205,12 @@ GameManager.prototype = {
                this.networkManager.joinStage(stage);
                //runningStageに登録することで、イベントの通知が開始され、GameStageは実行状態に入る。
                this.runningStage = stage;
+               
+               if(this.stageStartedEvent)
+               {
+                       this.stageStartedEvent.apply(window, [stage]);
+               }
+               
        },
        pauseStage: function(func){
                //ステージの実行を一時停止する。一時停止中、funcに指定された関数が毎tick毎に呼ばれる
@@ -242,6 +252,11 @@ GameManager.prototype = {
                        {
                                this.removeWidget(this.runningWidgets[0]);
                        }
+                       
+                       if(this.stageStoppedEvent)
+                       {
+                               this.stageStoppedEvent.apply(window, [aGameStage]);
+                       }
                }
        },
        loadStageFromLocal: function(code){
index 1a44985..e7a4092 100644 (file)
@@ -34,6 +34,16 @@ onload = function()
        //最初はグローバルデバッグモードはオフ
        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"))
        {
@@ -80,7 +90,7 @@ function reload()
 </script>
 </head>
 <body>
-       <div id="MainArea" style="width: 640px; height: 480px"></div>
+       <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>