OSDN Git Service

stopStage()時に全Widgetがdetachされるように
authorttwilb <ttwilb@users.sourceforge.jp>
Mon, 26 Aug 2013 13:38:56 +0000 (22:38 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Mon, 26 Aug 2013 13:38:56 +0000 (22:38 +0900)
(Widgetがステージリスタート後も画面を占有し続ける問題の解決)

www/corelib/core.js

index c8b383b..2c8dc87 100644 (file)
@@ -102,7 +102,7 @@ function GameManager(parent, debugTextName){
        this.runningStage = null;
        this.runningStageName = null;
        //現在存在しているWidghetのリストを格納
-       this.runningWidghets = [];
+       this.runningWidgets = [];
        
        //タイマーカウントを初期化
        this.tickCount = 0;
@@ -136,8 +136,8 @@ GameManager.prototype = {
                // runningStage.timerTick() 内でpauseStage()された時、ここで再度判定しないとWidghetのtickが実行されてしまう
                if(this.stagePausedFunction == null){
                        //ウィジェット
-                       for(var i = 0; i < this.runningWidghets.length; i++){
-                               var w = this.runningWidghets[i];
+                       for(var i = 0; i < this.runningWidgets.length; i++){
+                               var w = this.runningWidgets[i];
                                if(!w.tick()){
                                        // Widghetのtick()からfalseで帰ってきたらWidghetを開放
                                        this.removeWidget(w);
@@ -156,8 +156,8 @@ GameManager.prototype = {
                        this.runningStage.draw();
                }
                //ウィジェット
-               for(var i = 0; i < this.runningWidghets.length; i++){
-                       var w = this.runningWidghets[i];
+               for(var i = 0; i < this.runningWidgets.length; i++){
+                       var w = this.runningWidgets[i];
                        w.draw();
                }
                
@@ -176,10 +176,10 @@ GameManager.prototype = {
        },
        addWidget: function(w){
                w.attach();
-               this.runningWidghets.push(w);
+               this.runningWidgets.push(w);
        },
        removeWidget: function(w){
-               removeObjectFromArray(this.runningWidghets, w);
+               removeObjectFromArray(this.runningWidgets, w);
                w.detach();
        },
        runStage: function(stage){
@@ -236,6 +236,12 @@ GameManager.prototype = {
                        aGameStage.debugCanvas = null;
                        aGameStage.mainContext = null;
                        aGameStage.debugContext = null;
+                       
+                       //画面上に表示されたすべてのWidgetを解放する
+                       for(;this.runningWidghets.length>0;)
+                       {
+                               this.removeWidget(this.runningWidghets[0]);
+                       }
                }
        },
        loadStageFromLocal: function(code){