Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/src/js/jgame.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 78 by tsugehara, Wed Apr 3 12:16:41 2013 UTC revision 79 by tsugehara, Thu Apr 4 03:45:16 2013 UTC
# Line 2362  var InputKeyboardEvent = (function (_sup Line 2362  var InputKeyboardEvent = (function (_sup
2362  })(InputEvent);  })(InputEvent);
2363  var InputPointEvent = (function (_super) {  var InputPointEvent = (function (_super) {
2364      __extends(InputPointEvent, _super);      __extends(InputPointEvent, _super);
2365      function InputPointEvent(action, e, entity, point) {      function InputPointEvent(action, e, point) {
2366          _super.call(this, InputEventType.Point, action, e);          _super.call(this, InputEventType.Point, action, e);
2367            this.point = point;
2368        }
2369        InputPointEvent.prototype.set = function (entity) {
2370          var entityOffset = entity.offset();          var entityOffset = entity.offset();
2371          this.entity = entity;          this.entity = entity;
         this.point = point;  
2372          this.x = this.point.x - entityOffset.x;          this.x = this.point.x - entityOffset.x;
2373          this.y = this.point.y - entityOffset.y;          this.y = this.point.y - entityOffset.y;
2374      }      };
2375      return InputPointEvent;      return InputPointEvent;
2376  })(InputEvent);  })(InputEvent);
2377  var Renderer = (function () {  var Renderer = (function () {
# Line 2879  var Game = (function () { Line 2881  var Game = (function () {
2881          };          };
2882      };      };
2883      Game.prototype.onmousedown = function (e) {      Game.prototype.onmousedown = function (e) {
2884          var layers = this.scene.getLayerArray();          this.isPointDown = true;
2885          var layer;          this.eventQueue.push(new InputPointEvent(InputEventAction.Down, e, this.getOffsetByEvent(e)));
         var offset = this.getOffsetByEvent(e);  
         while(layer = layers.pop()) {  
             if(!layer.pointCapture) {  
                 continue;  
             }  
             var dragObj = layer.getEntityByPoint(offset);  
             if(!dragObj) {  
                 dragObj = layer;  
             }  
             this.dragParam = new InputPointEvent(InputEventAction.Down, e, dragObj, offset);  
             this.eventQueue.push(this.dragParam);  
             break;  
         }  
2886          e.preventDefault();          e.preventDefault();
2887      };      };
2888      Game.prototype.ontouchstart = function (e) {      Game.prototype.ontouchstart = function (e) {
         var layers = this.scene.getLayerArray();  
         var layer;  
2889          var touches = e.changedTouches;          var touches = e.changedTouches;
2890            this.isPointDown = true;
2891          for(var i = 0, l = touches.length; i < l; i++) {          for(var i = 0, l = touches.length; i < l; i++) {
2892              var touch = touches[i];              this.eventQueue.push(new InputPointEvent(InputEventAction.Down, touches[i], this.getOffsetByEvent(touches[i])));
             var offset = this.getOffsetByEvent(touch);  
             while(layer = layers.pop()) {  
                 if(!layer.pointCapture) {  
                     continue;  
                 }  
                 var dragObj = layer.getEntityByPoint(offset);  
                 if(!dragObj) {  
                     dragObj = layer;  
                 }  
                 this.dragParam = new InputPointEvent(InputEventAction.Down, touch, dragObj, offset);  
                 this.eventQueue.push(this.dragParam);  
                 break;  
             }  
2893          }          }
2894          e.preventDefault();          e.preventDefault();
2895      };      };
2896      Game.prototype.onmousemove = function (e) {      Game.prototype.onmousemove = function (e) {
2897          if(!this.dragParam) {          if(!this.isPointDown) {
2898              return;              return;
2899          }          }
2900          var param = new InputPointEvent(InputEventAction.Move, e, this.dragParam.entity, this.getOffsetByEvent(e));          this.eventQueue.push(new InputPointEvent(InputEventAction.Move, e, this.getOffsetByEvent(e)));
         this.eventQueue.push(param);  
2901          e.preventDefault();          e.preventDefault();
2902      };      };
2903      Game.prototype.ontouchmove = function (e) {      Game.prototype.ontouchmove = function (e) {
2904          if(!this.dragParam) {          if(!this.isPointDown) {
2905              return;              return;
2906          }          }
2907          var touches = e.changedTouches;          var touches = e.changedTouches;
2908          for(var i = 0, l = touches.length; i < l; i++) {          for(var i = 0, l = touches.length; i < l; i++) {
2909              var touch = touches[i];              this.eventQueue.push(new InputPointEvent(InputEventAction.Move, touches[i], this.getOffsetByEvent(touches[i])));
             var offset = this.getOffsetByEvent(touch);  
             var param = new InputPointEvent(InputEventAction.Move, touch, this.dragParam.entity, offset);  
             this.eventQueue.push(param);  
2910          }          }
2911          e.preventDefault();          e.preventDefault();
2912      };      };
2913      Game.prototype.onmouseup = function (e) {      Game.prototype.onmouseup = function (e) {
2914          if(!this.dragParam) {          if(!this.isPointDown) {
2915              return;              return;
2916          }          }
2917          var param = new InputPointEvent(InputEventAction.Up, e, this.dragParam.entity, this.getOffsetByEvent(e));          this.eventQueue.push(new InputPointEvent(InputEventAction.Up, e, this.getOffsetByEvent(e)));
2918          this.eventQueue.push(param);          this.isPointDown = false;
         this.dragParam = null;  
2919          e.preventDefault();          e.preventDefault();
2920      };      };
2921      Game.prototype.ontouchend = function (e) {      Game.prototype.ontouchend = function (e) {
2922          if(!this.dragParam) {          if(!this.isPointDown) {
2923              return;              return;
2924          }          }
2925          var touches = e.changedTouches;          var touches = e.changedTouches;
2926          for(var i = 0, l = touches.length; i < l; i++) {          for(var i = 0, l = touches.length; i < l; i++) {
2927              var touch = touches[i];              this.eventQueue.push(new InputPointEvent(InputEventAction.Up, touches[i], this.getOffsetByEvent(touches[i])));
             var offset = this.getOffsetByEvent(touch);  
             var param = new InputPointEvent(InputEventAction.Up, touch, this.dragParam.entity, offset);  
             this.eventQueue.push(param);  
2928          }          }
2929          this.dragParam = null;          this.isPointDown = false;
2930          e.preventDefault();          e.preventDefault();
2931      };      };
2932      Game.prototype.pointHandler = function () {      Game.prototype.pointHandler = function () {
# Line 3120  var Game = (function () { Line 3087  var Game = (function () {
3087          this.renderer.render();          this.renderer.render();
3088          this._exit = true;          this._exit = true;
3089      };      };
3090        Game.prototype.setPointingEntity = function (param) {
3091            var layers = this.scene.getLayerArray();
3092            var layer;
3093            var offset = param.point;
3094            while(layer = layers.pop()) {
3095                if(!layer.pointCapture) {
3096                    continue;
3097                }
3098                var dragObj = layer.getEntityByPoint(offset);
3099                if(!dragObj) {
3100                    dragObj = layer;
3101                }
3102                param.set(dragObj);
3103                this.dragParam = param;
3104                break;
3105            }
3106        };
3107      Game.prototype.raiseInputEvent = function () {      Game.prototype.raiseInputEvent = function () {
3108          var e;          var e;
3109          while(e = this.eventQueue.shift()) {          while(e = this.eventQueue.shift()) {
# Line 3130  var Game = (function () { Line 3114  var Game = (function () {
3114                  }                  }
3115                  this[n].fire(e);                  this[n].fire(e);
3116              } else {              } else {
3117                    if(e.action == InputEventAction.Down) {
3118                        this.setPointingEntity(e);
3119                    } else {
3120                        (e).set(this.dragParam.entity);
3121                    }
3122                  if((e).entity[n]) {                  if((e).entity[n]) {
3123                      (e).entity[n].fire(e);                      (e).entity[n].fire(e);
3124                  }                  }

Legend:
Removed from v.78  
changed lines
  Added in v.79

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26