OSDN Git Service

add placetree command and yukkuri sky bug update
authornagoling <>
Sun, 6 Oct 2013 15:39:54 +0000 (00:39 +0900)
committernagomi <nagomi@192.168.1.23>
Sun, 6 Oct 2013 15:39:54 +0000 (00:39 +0900)
main.js

diff --git a/main.js b/main.js
index 19a686a..6a12e67 100644 (file)
--- a/main.js
+++ b/main.js
@@ -45,6 +45,8 @@ var EResPath = {
        MAP0 : './data/map0.png',
        COMMAND : './data/command.png',
        OKAZARI : './data/okazari.png',
+       PLACE_TREE : './data/system/place_tree.png',
+       // PLACE_TREE : './data/system/rapture.png',
 };
 var EFace = {
        NORMAL:0,
@@ -67,6 +69,7 @@ var ECommand = {
        WORLD_CURSOR: 0,
        WORLD_TARGET: 1,
        WORLD_APPLE: 2,
+       WORLD_PLACE: 3,
 };
 
 var EMenuPos = {
@@ -120,12 +123,39 @@ var EMsg = {
        EAT_FAILED: 9,
        GREETING: 10,
 };
+var EWalkAnimation = {
+       START: 0,
+       END: 1,
+};
+enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
+       var params = {
+               x: function() {
+                       return this.x + x;
+               },
+               y: function() {
+                       return this.y + y;
+               },
+               time: time,
+               easing: easing
+       };
+       //-Event register [onactionstart,onactiontick,onactionend]
+       if(eventFunctions !== undefined){
+               for(var key in eventFunctions){
+                       params[key] = eventFunctions[key];
+               }
+       }
+       return this.tween(params);
+};
+
+
+
 include("./lang/ja.js");
 window.onload = function(){
 
        //init game
        var def = new Object();
        var foodGroup = new Group();
+       // var placeGroup = new Group();
        var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
        var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
        var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
@@ -812,6 +842,37 @@ window.onload = function(){
                        return this.give;
                }
        });
+       var Place= enchant.Class.create(ObjSprite,{
+               initialize: function (type, x, y){
+                       ObjSprite.call(this,128,128);
+                       this.image = game.assets[EResPath.PLACE_TREE];
+                       this.x = x - this.width / 2;
+                       this.y = y - this.height / 2;
+                       // placeGroup.addChild(this);
+                       backgroundMap.addChild(this);
+
+                       // this.addEventListener('enterframe', function(){
+
+
+                       //      if(this.age%10 === 0 && this.age !== 0){
+                       //              console.log("x/y " + this.x + "/" + this.y);
+                       //      }
+                       //      if(game.input.left){
+                       //              this.x -= 10;;
+                       //      }
+                       //      if(game.input.right){
+                       //              this.x += 10;;
+                       //      }
+                       //      if(game.input.up){
+                       //              this.y -= 10;;
+                       //      }
+                       //      if(game.input.down){
+                       //              this.y += 10;;
+                       //      }
+                       // });
+
+               }
+       });
        var Unun = enchant.Class.create(ObjSprite,{
                initialize: function (x, y){
                        this.classname = "Unun";
@@ -859,6 +920,7 @@ window.onload = function(){
                        this.bodyStatus ={};
                        this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
                        this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
+                       this.walkAnimationStatus = EWalkAnimation.END;
                },
                runEnterframe:function(){
                        this.act();
@@ -901,8 +963,7 @@ window.onload = function(){
                                        params[key] = eventFunctions[key];
                                }
                        }
-                       this.imgGroup.tl.tween(params);
-
+                       return this.imgGroup.tl.tween(params);
                },
                wait:function(frame, eventFunctions){
                        this.moveBy(0,1,frame,eventFunctions);
@@ -911,11 +972,27 @@ window.onload = function(){
                        this.action.act();
                },
                animation: function(){
-                       this.imgBody.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
-                       // this.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
-                       // this.okazari.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
-                       // this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
-                       // this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
+                       if(this.walkAnimationStatus == EWalkAnimation.END){
+                               this.imgBody.tl.moveByEx(0, -5, 10, enchant.Easing.SWING, {
+                                       "onactionstart": function(e){
+                                               this.walkAnimationStatus = EWalkAnimation.START;
+                                       }
+                               })
+                               .moveByEx(0, 5, 10, enchant.Easing.SWING,
+                               {
+                                       "onactionend": function(e){
+                                               this.walkAnimationStatus = EWalkAnimation.END;
+                                       }
+                               }).loop();
+
+                       }else{
+                               this.imgBody.tl.loop();
+                       }
+                       // this.imgBody.tl.moveByEx(0, -5, 10, enchant.Easing.SWING)
+                       // this.imgBody.tl.moveByEx(0, 5, 10, enchant.Easing.SWING);
+                       // this.imgBody.tl.loop();
+                       // this.moveBy(0, -5, 10).moveBy(0, 5, 10).loop();
+
                },
                getWidth: function(){
                        return this.width;
@@ -1071,8 +1148,8 @@ window.onload = function(){
                tlPause:function(){
                        // this.imgBody.tl.pause();
                        // this.imgGroup.tl.pause();
-                       this.imgBody.tl.clear();
-                       this.imgGroup.tl.clear();
+                       // this.imgBody.tl.clear();
+                       // this.imgGroup.tl.clear();
                        this.imgBody.tl.unloop();
                        this.imgGroup.tl.unloop();
                },
@@ -1219,23 +1296,23 @@ window.onload = function(){
                                this.act();
                                ///////////////////////////////////////////////
                                //Action pattern  debug
-                               if(game.input.left){
-                                       // this.changeFace(EResPath.MARISA_FACE_TIRED);
-                                       this.moveX(-10);
-                                       this.direction = EDirection.LEFT;
-                               }
-                               if(game.input.right){
-                                       this.moveX(10);
-                                       this.direction = EDirection.RIGHT;
-                               }
-                               if(game.input.up){
-                                       this.moveY(-10);
-                                       this.tweet("ゆっくりしていってね!");
+                               // if(game.input.left){
+                               //      // this.changeFace(EResPath.MARISA_FACE_TIRED);
+                               //      this.moveX(-10);
+                               //      this.direction = EDirection.LEFT;
+                               // }
+                               // if(game.input.right){
+                               //      this.moveX(10);
+                               //      this.direction = EDirection.RIGHT;
+                               // }
+                               // if(game.input.up){
+                               //      this.moveY(-10);
+                               //      this.tweet("ゆっくりしていってね!");
 
-                               }
-                               if(game.input.down){
-                                       this.moveY(10);
-                               }
+                               // }
+                               // if(game.input.down){
+                               //      this.moveY(10);
+                               // }
                                ///////////////////////////////////////////////
                                // this.reverse();
                                // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
@@ -1254,6 +1331,7 @@ window.onload = function(){
        });
        game.onload = function(){
                def.Food = Food;
+               def.Place = Place;
                mangTouch = new MangTouch(ctl);
                mangMsg = new MangMsg(ctl);
                ctl.setDefined(def);
@@ -1302,6 +1380,7 @@ window.onload = function(){
 
                // var food = new def.Food("apple", 200, 250);
                backgroundMap.addChild(foodGroup);
+               // backgroundMap.addChild(placeGroup);
                var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
                new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
                var touchX = 0;
@@ -1339,8 +1418,17 @@ window.onload = function(){
                                        else if(typeof b.id === "undefined"){
                                                return 1;
                                        }
-                                       if(a.y < b.y)return -1;
-                                       if(a.y > b.y)return 1;
+                                       var ay = a.y;
+                                       var by = b.y;
+                                       if(a instanceof Place){
+                                               ay += Math.round(a.height * 0.7);
+                                       }
+                                       else if(b instanceof Place){
+                                               by += Math.round(b.height * 0.7);
+                                       }
+
+                                       if(ay < by)return -1;
+                                       if(ay > by)return 1;
                                        return 0;
                                }
                        );