OSDN Git Service

place tree bug fix
authornagoling <>
Tue, 8 Oct 2013 14:14:20 +0000 (23:14 +0900)
committernagomi <nagomi@192.168.1.23>
Tue, 8 Oct 2013 14:14:20 +0000 (23:14 +0900)
ctrl.js
main.js

diff --git a/ctrl.js b/ctrl.js
index 2b2be9f..326a1d2 100644 (file)
--- a/ctrl.js
+++ b/ctrl.js
@@ -7,6 +7,7 @@ var Ctrl = enchant.Class.create({
                this.player = null;
                this.objArray = {};
                this.def = null;
+               this.objSprite = null;
        },
        init : function (game){
                this.game = game;
@@ -33,6 +34,12 @@ var Ctrl = enchant.Class.create({
        setPlayer: function(player){
                this.player = player;
        },
+       setCurrentObjSprite: function(objSprite){
+               this.objSprite = objSprite;
+       },
+       getCurrentObjSprite: function(objSprite){
+               return this.objSprite;
+       },
        /**
         * [setCurrentCommand description]
         * @param {ECommand} cmd [description]
@@ -113,6 +120,27 @@ var WorldCursorTouchEvent = enchant.Class.create(ATouchEvent,{
        touchstart : function(e){
                this.touchX = e.x - this.ctl.backgroundMap.x;
                this.touchY = e.y - this.ctl.backgroundMap.y;
+               var tx = this.touchX;
+               var ty = this.touchY;
+               var nodes = this.ctl.getObjs();
+               for (var id in nodes) {
+                       var node = nodes[id];
+                       var nx = node.getX();
+                       var ny = node.getY();
+                       // if(node.id === undefined)continue;
+                       if(node instanceof this.ctl.def.Yukkuri){
+                               nx -= node.width / 2;
+                               ny -= node.height / 2;
+                       }
+                       if(     nx <= tx
+                               && (nx + node.width) >= tx
+                               && ny <= ty
+                               && (ny + node.height) >= ty
+                               ){
+                               console.log("hiT!");
+                       }
+               }
+
        },
        touchmove : function(e){
                var backgroundMap = this.ctl.backgroundMap;
@@ -338,7 +366,6 @@ var MangLabel = enchant.Class.create({
                        var labelObj = this.labelParams[key];
                        labelObj.draw(yukkuriObj);
                }
-
        }
 });
 var MangMsg = enchant.Class.create({
diff --git a/main.js b/main.js
index 1ed5b20..6768255 100644 (file)
--- a/main.js
+++ b/main.js
@@ -214,17 +214,22 @@ window.onload = function(){
                                break;
                                case EAction.THINK:
                                        if(this.yukkuri.age%2 === 0){
-                                               if(this.yukkuri.isSleep()){
-                                                       this.setStatus(EAction.SLEEP_START);
-                                               }
-                                               else if(this.yukkuri.getUnun() >= 80){
-                                                       this.setStatus(EAction.UNUN_START);
-                                               }
-                                               else{
-                                                       // this.yukkuri.param.yukkuri -= 1;
-                                                       this.yukkuri.changeFace();
-                                                       this.search();
-                                               }
+                                               // if(this.yukkuri.isPlace()){
+
+                                               // }
+                                               // else{
+                                                       if(this.yukkuri.isSleep()){
+                                                               this.setStatus(EAction.SLEEP_START);
+                                                       }
+                                                       else if(this.yukkuri.getUnun() >= 80){
+                                                               this.setStatus(EAction.UNUN_START);
+                                                       }
+                                                       else{
+                                                               // this.yukkuri.param.yukkuri -= 1;
+                                                               this.yukkuri.changeFace();
+                                                               this.search();
+                                                       }
+                                               // }
 
                                        }
                                break;
@@ -877,6 +882,12 @@ window.onload = function(){
                        this.id = guid();
                        ctl.addObj(this);
                },
+               getX: function(){
+                       return this.x;
+               },
+               getY: function(){
+                       return this.y;
+               },
                removeAll: function(){
                        this.remove();
                        ctl.removeObj(this);
@@ -916,6 +927,7 @@ window.onload = function(){
                        this.y = y - this.height / 2;
                        backgroundMap.addChild(this);
                        this.owner = null;
+
                        // this.addEventListener('enterframe', function(){
                        //      if(this.age%10 === 0 && this.age !== 0){
                        //              console.log("x/y " + this.x + "/" + this.y);
@@ -1003,6 +1015,8 @@ window.onload = function(){
                        this.place = null;
                },
                runEnterframe:function(){
+                       // this.imgGroup.x = 0;
+                       // return ;
                        this.act();
                        if(this.isDead())return;
                        this.runYukkuri();
@@ -1271,7 +1285,6 @@ window.onload = function(){
                        Yukkuri.call(this,x,y);
                        this.classname = "Marisa";
 
-
                        // var xml = this.loadParamsXML("./data/marisa/params.xml");
                        var json = net.load("./data/marisa/params.json");
                        this.param = json.root.param;
@@ -1328,7 +1341,6 @@ window.onload = function(){
                        this.imgGroup.y = y;
                        this.animation();
                        this.action = new Action(this);
-                       this.id = guid();
                        ctl.addObj(this);
                },
                setFaceImage: function(eface){
@@ -1387,6 +1399,8 @@ window.onload = function(){
        game.onload = function(){
                def.Food = Food;
                def.Place = Place;
+               def.ObjSprite = ObjSprite;
+               def.Yukkuri = Yukkuri;
                mangTouch = new MangTouch(ctl);
                mangMsg = new MangMsg(ctl);
                ctl.setDefined(def);
@@ -1476,15 +1490,18 @@ window.onload = function(){
                                        }
                                        var ay = a.y;
                                        var by = b.y;
+
                                        if(a instanceof Place){
                                                ay += Math.round(a.height * 0.7);
                                        }
-                                       else if(b instanceof Place){
+                                       if(b instanceof Place){
                                                by += Math.round(b.height * 0.7);
                                        }
 
                                        if(ay < by)return -1;
-                                       if(ay > by)return 1;
+                                       else if(ay > by)return 1;
+                                       if(a.id < b.id)return -1;
+                                       else if(a.id > b.id)return 1;
                                        return 0;
                                }
                        );