OSDN Git Service

Timeが全体で共有されるように
authorttwilb <ttwilb@users.sourceforge.jp>
Thu, 5 Sep 2013 09:21:03 +0000 (18:21 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Thu, 5 Sep 2013 09:21:03 +0000 (18:21 +0900)
www/corelib/classes/TimerWidgetClass.js

index 53c8c8c..ebc667d 100644 (file)
@@ -6,13 +6,16 @@
        this.size = new Point2D(128, 24);
        this.origin = new Point2D(5, 5);
 
-       this.wBox = null;
-       
-       this.startTimeStamp = 0;
-       this.timerRunning = false;
-       this.gameTime = 7 * 60 * 1000;
        
-       this.warnType = 0;
+       this.wBox = null;
+       if(!this.manager.startTimeStamp)
+       {
+               this.manager.startTimeStamp = 0;
+               this.manager.timerRunning = false;
+               this.manager.gameTime = 7 * 60 * 1000;
+               
+               this.manager.warnType = 0;
+       }
        
 }.extend(WidgetClass, {
        attach : function(){
@@ -35,8 +38,8 @@
                this.manager.mainArea.appendChild(element);
                this.wBox = element;
                
-               this.startTimeStamp = (+new Date());
-               this.timerRunning = true;
+               this.manager.startTimeStamp = (+new Date());
+               this.manager.timerRunning = true;
        },
        detach : function()
        {
        },
        tick : function()
        {
-               if(this.timerRunning)
+               if(this.manager.timerRunning)
                {
-                       var past = (+new Date()) - this.startTimeStamp;
-                       if(past > this.gameTime)
+                       var past = (+new Date()) - this.manager.startTimeStamp;
+                       if(past > this.manager.gameTime)
                        {
-                               this.timerRunning = false;
+                               this.manager.timerRunning = false;
                                var that = this;
                                this.manager.addWidget(new MessageWidgetClass(this.manager,["おわり。\n", null, function(){
                                        that.loadStageFromNetwork('panya');
                                }]));
                        }else
                        {
-                               var rate = past / this.gameTime;
+                               var rate = past / this.manager.gameTime;
                                
                                if(rate < 0.8)
                                {
@@ -79,7 +82,7 @@
                
                
                
-               var time = this.gameTime - ((+new Date()) - this.startTimeStamp);
+               var time = this.manager.gameTime - ((+new Date()) - this.manager.startTimeStamp);
                var min = Math.floor(time / (60 * 1000));
                var sec = Math.floor((time - (min * 60 * 1000)) / 1000);
                var msec = (time - (min * 60 * 1000) - (sec * 1000));