OSDN Git Service

update
authornagoling <>
Sun, 29 Dec 2013 20:45:50 +0000 (05:45 +0900)
committernagomi <nagomi@192.168.1.23>
Sun, 29 Dec 2013 20:45:50 +0000 (05:45 +0900)
lib/Animation.js
lib/FormSprite.js
main.js
php/lib/Animation.js [deleted file]
php/lib/FormSprite.js [deleted file]

index 0760b69..ceeacf0 100644 (file)
@@ -1,28 +1,50 @@
 var Animation = enchant.Class.create({
        initialize: function (sprite){
                this.cnt = 0;
+               this.cntUp = 0;
+               this.cntDown = 0;
+               this.accCnt = 0;
                this.maxY = -4;
                this.minY = 0;
                this.y = 0;
                this.speed = 0.5;
                this.sprite = sprite;
                this.status = EAnimStatus.UP;
+               this.stop = false;
+
        },
-       animrun: function(){
+       runAnim: function(){
                if(this.cnt <= this.maxY){
                        this.status = EAnimStatus.DOWN;
                }
                else if(this.cnt >= this.minY){
                        this.status = EAnimStatus.UP;
-
                }
+               if(this.stop)return;
                if(this.status == EAnimStatus.UP){
                        this.sprite.y -= this.speed;
                        this.cnt -= this.speed;
+                       this.cntUp -= this.speed;
                }
                else if(this.status == EAnimStatus.DOWN){
                        this.sprite.y += this.speed;
                        this.cnt += this.speed;
+                       this.cntDown += this.speed;
                }
-       }
+               if(this.cnt != (this.cntUp + this.cntDown)){
+                       console.log(this.cnt + "@" + this.cntUp + ":" + this.cntDown);
+               }
+               // console.log(this.cnt);
+       },
+       startAnim:function(){
+               // console.log("start:" + this.cnt);
+               this.stop = false;
+       },
+       stopAnim: function(){
+               this.sprite.y -= this.cnt;
+               this.cntUp = 0;
+               this.cntDown = 0;
+               this.cnt = 0;
+               this.stop = true;
+       },
 });
\ No newline at end of file
index c4fd3ef..4714892 100644 (file)
@@ -3,6 +3,7 @@ var FormSprite = enchant.Class.create({
                this.spriteArray = [];
                this.id = guid();
                this.mainIndex = 0;
+               this.shadowIndex = 0;
        },
        addChild:function(sprite, index, attr){
                this.add(sprite, index, attr);
@@ -24,8 +25,10 @@ var FormSprite = enchant.Class.create({
        // },
        /**
        attr: 
-               mainIndex:true/false
+               mainIndexFlg:true/false
+               shadowIndexFlg:true/false
                type:body/tweet
+
        */
        add : function(sprite, index, attr){
                if(attr === undefined)attr = {};
@@ -36,6 +39,9 @@ var FormSprite = enchant.Class.create({
                if(attr.mainIndexFlg){
                        this.mainIndex = index;
                }
+               if(attr.shadowIndexFlg){
+                       this.shadowIndex = index;
+               }
                // this.spriteArray.push(sprite);
        },
        remove: function (sprite){
@@ -55,6 +61,15 @@ var FormSprite = enchant.Class.create({
                        spr.y += y;
                }
        },
+       getMainSprite: function(){
+               return this.spriteArray[this.mainIndex];
+       },
+       getShadowSprite: function(){
+               return this.spriteArray[this.shadowIndex];
+       },
+       getMainShadowMarginY: function(){
+               return Math.round(this.getMainSprite().y - this.getShadowSprite().y);
+       },
        getX: function(){
                return Math.round(this.spriteArray[this.mainIndex].x,2) - this.spriteArray[this.mainIndex].baseX;
        },
@@ -75,6 +90,15 @@ var FormSprite = enchant.Class.create({
                        spr.y = y + spr.baseY;
                }
        },
+       addBodyY: function(y){
+               for(var i=0;i<this.spriteArray.length;i++){
+                       if(this.spriteArray[i] === undefined)continue;
+                       var spr = this.spriteArray[i];
+                       if(spr.type == "body" || spr.type == "budge"){
+                               this.spriteArray[i].y += y;
+                       }
+               }
+       },
        setFixBudgeLeft: function (index){
                this.spriteArray[index].x = this.spriteArray[this.mainIndex].x + this.spriteArray[this.mainIndex].width / 3 * 2;
                this.spriteArray[index].scaleX = 1;
@@ -144,12 +168,36 @@ var FormSprite = enchant.Class.create({
        tlQueueLength:function(){
                return this.spriteArray[this.mainIndex].tl.queue.length;
        },
-       animation: function(){
+       formRunAnimation: function(){
+               if(this.getMainShadowMarginY() < -8){
+                       this.addBodyY(+1);
+               }
+               else if(this.getMainShadowMarginY() > 0){
+                       this.addBodyY(-1);
+               }
+               for(var i=0;i<this.spriteArray.length;i++){
+                       if(this.spriteArray[i] === undefined)continue;
+                       var spr = this.spriteArray[i];
+                       if(spr.type == "body" || spr.type == "budge"){
+                               spr.anim.runAnim();
+                       }
+               }
+       },
+       formStartAnimation: function(){
+               for(var i=0;i<this.spriteArray.length;i++){
+                       if(this.spriteArray[i] === undefined)continue;
+                       var spr = this.spriteArray[i];
+                       if(spr.type == "body" || spr.type == "budge"){
+                               spr.anim.startAnim();
+                       }
+               }
+       },
+       formStopAnimation: function(){
                for(var i=0;i<this.spriteArray.length;i++){
                        if(this.spriteArray[i] === undefined)continue;
                        var spr = this.spriteArray[i];
                        if(spr.type == "body" || spr.type == "budge"){
-                               spr.anim.animrun();
+                               spr.anim.stopAnim();
                        }
                }
        },
diff --git a/main.js b/main.js
index 7691739..9da106e 100644 (file)
--- a/main.js
+++ b/main.js
@@ -944,6 +944,14 @@ window.onload = function(){
                                yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
                                return;
                        }
+                       if(yukkuri.isSleep()){
+                               yukkuri.action.setStatus(EAction.SLEEP_START);
+                               return;
+                       }
+                       else if(yukkuri.getUnun() >= 80){
+                               yukkuri.action.setStatus(EAction.UNUN_START);
+                               return;
+                       }
 
                        if(yukkuri.isItemsMax() && yukkuri.isPlace()){
                                yukkuri.action.targetNode = yukkuri.getPlace();
@@ -978,15 +986,6 @@ window.onload = function(){
                                return;
                        }
 
-                       if(yukkuri.isSleep()){
-                               yukkuri.action.setStatus(EAction.SLEEP_START);
-                               return;
-                       }
-
-                       else if(yukkuri.getUnun() >= 80){
-                               yukkuri.action.setStatus(EAction.UNUN_START);
-                               return;
-                       }
 
 
                        if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
@@ -2042,7 +2041,8 @@ window.onload = function(){
                                        this.runUnun();
                                        this.runSleep();
                                        this.runAddress();
-                                       this.formSprite.animation();
+                                       this.runAnimation();
+                                       // this.animation();
 
                                }
                        // }catch(e){
@@ -2109,9 +2109,11 @@ window.onload = function(){
                act: function(){
                        this.action.act();
                },
-
+               runAnimation: function(){
+                       this.formSprite.formRunAnimation();
+               },
                animation: function(){
-                       this.formSprite.animation();
+                       this.formSprite.formStartAnimation();
                        // var frame = 10;
                        // frame -= plusFrameScale(frame, this.getMyScale()) / 2;
                        // var move = 5;
@@ -2196,7 +2198,7 @@ window.onload = function(){
                },
                runSleep: function(){
                        if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
-                               if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
+                               if(this.age%80 === 0 && this.age !== 0)this.param.sleep += 1;
                                if(this.param.sleep >= 100){
                                        this.param.sleep = 100;
                                }
@@ -2345,7 +2347,7 @@ window.onload = function(){
                        // this.imgBody.tl.unloop();
                        // this.imgGroup.tl.unloop();
                        // this.imgBody.y = 0;
-
+                       this.formSprite.formStopAnimation();
                },
                tlResume: function(){
                        // this.imgBody.tl.resume();
@@ -2618,7 +2620,7 @@ window.onload = function(){
                        this.kukis[3] = new Kuki(this, -5, 5);
                        this._tweet = new TTweet(this, 148, 64);
 
-                       this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
+                       this.formSprite.addChild(this.shadow,0,{type:"shadow",shadowIndexFlg:true,scaleValue:this.myScaleY});
                        this.formSprite.addChild(this, 1, {
                                mainIndexFlg:true,
                                type : "body",
@@ -2901,7 +2903,7 @@ window.onload = function(){
                // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
                // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
                // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
-               new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
+               //new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
                // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
                // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
                // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
diff --git a/php/lib/Animation.js b/php/lib/Animation.js
deleted file mode 100644 (file)
index 0760b69..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-var Animation = enchant.Class.create({
-       initialize: function (sprite){
-               this.cnt = 0;
-               this.maxY = -4;
-               this.minY = 0;
-               this.y = 0;
-               this.speed = 0.5;
-               this.sprite = sprite;
-               this.status = EAnimStatus.UP;
-       },
-       animrun: function(){
-               if(this.cnt <= this.maxY){
-                       this.status = EAnimStatus.DOWN;
-               }
-               else if(this.cnt >= this.minY){
-                       this.status = EAnimStatus.UP;
-
-               }
-               if(this.status == EAnimStatus.UP){
-                       this.sprite.y -= this.speed;
-                       this.cnt -= this.speed;
-               }
-               else if(this.status == EAnimStatus.DOWN){
-                       this.sprite.y += this.speed;
-                       this.cnt += this.speed;
-               }
-       }
-});
\ No newline at end of file
diff --git a/php/lib/FormSprite.js b/php/lib/FormSprite.js
deleted file mode 100644 (file)
index 0f289c6..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-var FormSprite = enchant.Class.create({
-       initialize: function (){
-               this.spriteArray = [];
-               this.id = guid();
-               this.mainIndex = 0;
-       },
-       addChildAll:function(){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       this.spriteArray[i].baseX = this.spriteArray[i].x;
-                       this.spriteArray[i].baseY = this.spriteArray[i].y;
-                       this.spriteArray[i].anim = new Animation(this.spriteArray[i]);
-                       this.spriteArray[i].id = guid();
-                       App.backgroundMap.addChild(this.spriteArray[i]);
-               }
-       },
-       /**
-       attr: 
-               mainIndex:true/false
-               type:body/tweet
-       */
-       add : function(sprite, index, attr){
-               if(attr === undefined)attr = {};
-               this.spriteArray[index] = sprite;
-               this.spriteArray[index].type = attr.type;
-               this.spriteArray[index].scaleValue = attr.scaleValue;
-               if(attr.mainIndexFlg){
-                       this.mainIndex = index;
-               }
-               // this.spriteArray.push(sprite);
-       },
-       remove: function (sprite){
-               this.spriteArray.remove(sprite);
-       },
-       addX: function(x){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       spr.x += x;
-               }
-       },
-       addY: function(y){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       spr.y += y;
-               }
-       },
-       getX: function(){
-               return Math.round(this.spriteArray[this.mainIndex].x,2) - this.spriteArray[this.mainIndex].baseX;
-       },
-       getY: function(){
-               return Math.round(this.spriteArray[this.mainIndex].y,2) - this.spriteArray[this.mainIndex].baseY;
-       },
-       setX: function(x){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       spr.x = x + spr.baseX;
-               }
-       },
-       setY: function(y){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       spr.y = y + spr.baseY;
-               }
-       },
-       formScaleX: function(x){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       if(spr.type == "tweet")continue;
-                       spr.scaleX = x;
-               }
-       },
-       formScaleY: function(y){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       if(spr.type == "tweet")continue;
-                       spr.scaleY = y;
-               }
-       },
-       // tlTween:function(params){
-       //      console.log("tlTween");
-       //      for(var i=0;i<this.spriteArray.length;i++){
-       //              var spr = this.spriteArray[i];
-       //              spr.tl.tween(params);
-       //      }
-       // },
-       tlMoveBy:function(x, y, time, eventFunctions){
-               var self = this;
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       if(spr.type == "tweet")continue;
-
-                       // var addX = x + spr.baseX;
-                       // var addY = y + spr.baseX;
-                       var addX = x;
-                       var addY = y;
-                       // console.log(i+":spry:" + spr.y);
-                       var params = {
-                               x: this.paramX(spr.x, addX),
-                               y: this.paramY(spr.y, addY),
-                               time: time,
-                               easing: enchant.Easing.SIN_EASEINOUT
-                       };
-                       if(eventFunctions !== undefined && i == this.mainIndex){
-                               for(var key in eventFunctions){
-                                       params[key] = eventFunctions[key];
-                               }
-                       }
-                       spr.tl.tween(params);
-               }
-       },
-       paramX : function(x, addX){
-               return x  + addX;
-               // return function(){
-               //      return x  + addX;
-               // }
-       },
-       paramY : function(y, addY){
-               return y + addY;
-       },
-       tlMoveTo:function(x, y, time, easing ){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       spr.tl.moveTo(x, y, time, easing);
-               }
-       },
-       tlQueueLength:function(){
-               return this.spriteArray[this.mainIndex].tl.queue.length;
-       },
-       animation: function(){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       if(spr.type == "body"){
-                               spr.anim.animrun();
-                       }
-               }
-       },
-       scale: function(_scaleX,_scaleY){
-               for(var i=0;i<this.spriteArray.length;i++){
-                       var spr = this.spriteArray[i];
-                       if(spr.type == "tweet")continue;
-                       spr.scale(_scaleX, _scaleY);
-               }
-       },
-});
\ No newline at end of file