OSDN Git Service

試験的に擬似ウィンドウ作成
authornagoling <>
Mon, 30 Sep 2013 18:24:43 +0000 (03:24 +0900)
committernagomi <nagomi@192.168.1.23>
Mon, 30 Sep 2013 18:24:43 +0000 (03:24 +0900)
main.js

diff --git a/main.js b/main.js
index fc7ce79..ae211ae 100644 (file)
--- a/main.js
+++ b/main.js
@@ -120,6 +120,7 @@ window.onload = function(){
        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);
+       var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
        var game = new Game(GAME_WIDTH, GAME_HEIGHT);
        game.fps = FPS;
        var _loadArr = [];
@@ -223,6 +224,9 @@ window.onload = function(){
                                "myYukkuri": this.yukkuri
                        });
                },
+               walkNew: function(){
+
+               },
                walk : function(retryCounter){
                        if(retryCounter > 15){
                                retryCounter = 0;
@@ -238,7 +242,6 @@ window.onload = function(){
                                        this.yukkuri.vx = 0;
                                        this.yukkuri.vy = 0;
                                }else{
-                                       // this.isMoving = true;
                                        var xpos = 150 + rand(40) - (retryCounter * 10);
                                        var ypos = 150 + rand(40) - (retryCounter * 10);
                                        if(rand(8) === 0){
@@ -393,6 +396,26 @@ window.onload = function(){
                        };
                }
        });
+       var WalkEvent = enchant.Class.create(Event,{
+               initialize: function (_data){
+                       this.data = _data;
+                       this.yukkuri = _data.myYukkuri;
+                       this.action = _data.action;
+
+                       mangMsg.output(this.yukkuri, EMsg.SLEEP);
+                       this.action.setStatus(EAction.SLEEP_WAIT);
+                       this.yukkuri.setFaceImage(EFace.SLEEP);
+                       this.yukkuri.tlPause();
+                       var self = this;
+                       this.yukkuri.addEventListener('enterframe', function() {
+                               var yukkuri = self.yukkuri;
+                               self.run();
+                       });
+               },
+               run : function(){
+
+               }
+       });
        var SleepEvent = enchant.Class.create(Event,{
                initialize: function (_data){
                        this.data = _data;
@@ -404,91 +427,21 @@ window.onload = function(){
                        this.yukkuri.setFaceImage(EFace.SLEEP);
                        this.yukkuri.tlPause();
                        var sec = FPS * 3;
-                       // this.yukkuri.enterframe(function(){
-                       //      console.log("enterfmrae");
-                       // });
                        var self = this;
                        this.yukkuri.addEventListener('enterframe', function() {
                                var yukkuri = self.yukkuri;
                                if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
                                if(yukkuri.param.sleep <= 0){
                                        yukkuri.param.sleep = 0;
-                                       self.action.setStatus(EAction.WAIT);
+                                       this.removeEventListener("enterframe",arguments.callee);
                                        mangMsg.output(self.yukkuri, EMsg.GET_UP);
-                                       self.yukkuri.setFaceImage(EFace.NORMAL);
+                                       yukkuri.setFaceImage(EFace.NORMAL);
                                        yukkuri.tlResume();
-                                       this.removeEventListener("enterframe",arguments.callee);
+                                       // self.action.setStatus(EAction.WAIT);
                                        self.action.setStatus(EAction.THINK);
                                }
                        });
-               },
-               onactionstart:function(self){
-                       return function(e){
-                               if(typeof e === "undefined")return;
-                               console.log("astart");
-                       };
-               },
-               onactiontick:function(self){
-                       return function(e){
-                               if(typeof e === "undefined")return;
-                       };
-               },
-               onactionend:function(self){
-                       return function(e){
-                               if(typeof e === "undefined")return;
-                               console.log("enddd");
-                       };
                }
-
-               // initialize: function (_data){
-               //      console.log("init");
-               //      this.data = _data;
-               //      this.yukkuri = _data.myYukkuri;
-               //      this.action = _data.action;
-               //      this.action.setStatus(EAction.SLEEP_WAIT);
-               //      mangMsg.output(this.yukkuri, EMsg.SLEEP);
-               //      this.yukkuri.setFaceImage(EFace.SLEEP);
-               //      this.yukkuri.tlPause();
-
-               //      var sec = BASE_FPS * 1;
-               //      console.log("sec:"+ sec);
-               //      this.yukkuri.wait(sec, {
-               //              "onactionstart": this.onactionstart(this),
-               //              "onactiontick": this.onactiontick(this),
-               //              "onactionend": this.onactionend(this)
-               //      });
-               // },
-               // onactionstart:function(self){
-               //      return function(e){
-               //              console.log("start");
-               //              if(typeof e === "undefined")return;
-               //      };
-               // },
-               // onactiontick:function(self){
-               //      return function(e){
-               //              if(typeof e === "undefined")return;
-               //              console.log("tick");
-               //              var yukkuri = self.yukkuri;
-               //              if(yukkuri.age%4 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
-               //              if(yukkuri.param.sleep <= 0){
-               //                      yukkuri.param.sleep = 0;
-               //              }
-               //      };
-               // },
-               // onactionend:function(self){
-               //      return function(e){
-               //              if(typeof e === "undefined")return;
-               //              self.action.setStatus(EAction.WAIT);
-               //              self.yukkuri.setFaceImage(EFace.NORMAL);
-               //              mangMsg.output(self.yukkuri, EMsg.GET_UP);
-               //              yukkuri.tlResume();
-               //              new WaitEvent({
-               //                      "waitframe": FPS * 1.5,
-               //                      "action": self.action,
-               //                      "myYukkuri": self.yukkuri
-               //              });
-               //      };
-               // }
        });
 
        var UnunEvent = enchant.Class.create(Event,{
@@ -776,7 +729,6 @@ window.onload = function(){
                        this.image = game.assets[EResPath.YUKKURI_BASE];
                        this.direction = EDirection.RIGHT;
                        this.addEventListener('enterframe', this.runEnterframe);
-                       this.isSleeping = false;
                        this.bodyStatus ={};
                        this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
                        this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
@@ -1067,7 +1019,6 @@ window.onload = function(){
                                        // console.log("palyer:" + this.age);
                                }
                                this.act();
-
                                ///////////////////////////////////////////////
                                //Action pattern for debug
                                if(game.input.left){
@@ -1082,6 +1033,7 @@ window.onload = function(){
                                if(game.input.up){
                                        this.moveY(-10);
                                        this.tweet("ゆっくりしていってね!");
+
                                }
                                if(game.input.down){
                                        this.moveY(10);
@@ -1113,20 +1065,30 @@ window.onload = function(){
 
                var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
                var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
+               var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
                fieldBg.image = fieldSurface;
                fieldBg.x = 0;
                fieldBg.y = 0;
 
+               windowFront.image = windowSurface;
+               windowFront.x = 0;
+               windowFront.y = 0;
+               windowFront.opacity = 0.5;
+
+               windowSurface.context.fillStyle = '#000';
+               windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
+
+
                menuSurface.context.fillStyle = '#000';
                menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
                menuBg.image = menuSurface;
                menuBg.x = EMenuPos.X;
                menuBg.y = EMenuPos.Y;
-
                backgroundMap.addChild(fieldBg);
                mangIcon = new MangIcon(ctl, menuBg);
 
                game.rootScene.addChild(backgroundMap);
+               game.rootScene.addChild(windowFront);
                game.rootScene.addChild(menuBg);
 
                // var labelGroup = new LabelGroup();
@@ -1143,7 +1105,7 @@ window.onload = function(){
                // var food = new def.Food("apple", 200, 250);
                backgroundMap.addChild(foodGroup);
                var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
-               // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
+               new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
                var touchX = 0;
 
                game.rootScene.addEventListener('touchstart', function (e) {