Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/jgame.js

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

revision 150 by tsugehara, Sat Aug 10 03:44:21 2013 UTC revision 151 by tsugehara, Thu Aug 22 15:37:41 2013 UTC
# Line 5  var jg; Line 5  var jg;
5          Angle[Angle["Left"] = 1] = "Left";          Angle[Angle["Left"] = 1] = "Left";
6          Angle[Angle["Right"] = 2] = "Right";          Angle[Angle["Right"] = 2] = "Right";
7          Angle[Angle["Up"] = 3] = "Up";          Angle[Angle["Up"] = 3] = "Up";
   
8          Angle[Angle["Down"] = 4] = "Down";          Angle[Angle["Down"] = 4] = "Down";
9      })(jg.Angle || (jg.Angle = {}));      })(jg.Angle || (jg.Angle = {}));
10      var Angle = jg.Angle;      var Angle = jg.Angle;
# Line 14  var jg; Line 13  var jg;
13          RenderTransferMode[RenderTransferMode["Unknown"] = 0] = "Unknown";          RenderTransferMode[RenderTransferMode["Unknown"] = 0] = "Unknown";
14          RenderTransferMode[RenderTransferMode["Transfer"] = 1] = "Transfer";          RenderTransferMode[RenderTransferMode["Transfer"] = 1] = "Transfer";
15          RenderTransferMode[RenderTransferMode["Flip"] = 2] = "Flip";          RenderTransferMode[RenderTransferMode["Flip"] = 2] = "Flip";
   
16          RenderTransferMode[RenderTransferMode["Direct"] = 3] = "Direct";          RenderTransferMode[RenderTransferMode["Direct"] = 3] = "Direct";
17      })(jg.RenderTransferMode || (jg.RenderTransferMode = {}));      })(jg.RenderTransferMode || (jg.RenderTransferMode = {}));
18      var RenderTransferMode = jg.RenderTransferMode;      var RenderTransferMode = jg.RenderTransferMode;
# Line 22  var jg; Line 20  var jg;
20      (function (InputEventType) {      (function (InputEventType) {
21          InputEventType[InputEventType["Unknown"] = 0] = "Unknown";          InputEventType[InputEventType["Unknown"] = 0] = "Unknown";
22          InputEventType[InputEventType["Keyboard"] = 1] = "Keyboard";          InputEventType[InputEventType["Keyboard"] = 1] = "Keyboard";
   
23          InputEventType[InputEventType["Point"] = 2] = "Point";          InputEventType[InputEventType["Point"] = 2] = "Point";
24      })(jg.InputEventType || (jg.InputEventType = {}));      })(jg.InputEventType || (jg.InputEventType = {}));
25      var InputEventType = jg.InputEventType;      var InputEventType = jg.InputEventType;
# Line 31  var jg; Line 28  var jg;
28          InputEventAction[InputEventAction["Unknown"] = 0] = "Unknown";          InputEventAction[InputEventAction["Unknown"] = 0] = "Unknown";
29          InputEventAction[InputEventAction["Down"] = 1] = "Down";          InputEventAction[InputEventAction["Down"] = 1] = "Down";
30          InputEventAction[InputEventAction["Move"] = 2] = "Move";          InputEventAction[InputEventAction["Move"] = 2] = "Move";
   
31          InputEventAction[InputEventAction["Up"] = 3] = "Up";          InputEventAction[InputEventAction["Up"] = 3] = "Up";
32      })(jg.InputEventAction || (jg.InputEventAction = {}));      })(jg.InputEventAction || (jg.InputEventAction = {}));
33      var InputEventAction = jg.InputEventAction;      var InputEventAction = jg.InputEventAction;
# Line 43  var jg; Line 39  var jg;
39          Keytype[Keytype["Up"] = 3] = "Up";          Keytype[Keytype["Up"] = 3] = "Up";
40          Keytype[Keytype["Down"] = 4] = "Down";          Keytype[Keytype["Down"] = 4] = "Down";
41          Keytype[Keytype["Enter"] = 5] = "Enter";          Keytype[Keytype["Enter"] = 5] = "Enter";
   
42          Keytype[Keytype["Esc"] = 6] = "Esc";          Keytype[Keytype["Esc"] = 6] = "Esc";
43      })(jg.Keytype || (jg.Keytype = {}));      })(jg.Keytype || (jg.Keytype = {}));
44      var Keytype = jg.Keytype;      var Keytype = jg.Keytype;
# Line 60  var jg; Line 55  var jg;
55      (function (ShapeType) {      (function (ShapeType) {
56          ShapeType[ShapeType["Unknown"] = 0] = "Unknown";          ShapeType[ShapeType["Unknown"] = 0] = "Unknown";
57          ShapeType[ShapeType["Rect"] = 1] = "Rect";          ShapeType[ShapeType["Rect"] = 1] = "Rect";
   
58          ShapeType[ShapeType["Arc"] = 2] = "Arc";          ShapeType[ShapeType["Arc"] = 2] = "Arc";
59      })(jg.ShapeType || (jg.ShapeType = {}));      })(jg.ShapeType || (jg.ShapeType = {}));
60      var ShapeType = jg.ShapeType;      var ShapeType = jg.ShapeType;
# Line 99  var jg; Line 93  var jg;
93          EffectType[EffectType["BoxInWhite"] = 30] = "BoxInWhite";          EffectType[EffectType["BoxInWhite"] = 30] = "BoxInWhite";
94          EffectType[EffectType["BoxIn45White"] = 31] = "BoxIn45White";          EffectType[EffectType["BoxIn45White"] = 31] = "BoxIn45White";
95          EffectType[EffectType["ArcOutWhite"] = 32] = "ArcOutWhite";          EffectType[EffectType["ArcOutWhite"] = 32] = "ArcOutWhite";
   
96          EffectType[EffectType["ArcInWhite"] = 33] = "ArcInWhite";          EffectType[EffectType["ArcInWhite"] = 33] = "ArcInWhite";
97      })(jg.EffectType || (jg.EffectType = {}));      })(jg.EffectType || (jg.EffectType = {}));
98      var EffectType = jg.EffectType;      var EffectType = jg.EffectType;
# Line 158  var jg; Line 151  var jg;
151    
152          Rectangle.prototype.fit = function (point) {          Rectangle.prototype.fit = function (point) {
153              if (point.y < this.top)              if (point.y < this.top)
154                  point.y = this.top; else if (point.y > this.bottom)                  point.y = this.top;
155    else if (point.y > this.bottom)
156                  point.y = this.bottom;                  point.y = this.bottom;
157    
158              if (point.x < this.left)              if (point.x < this.left)
159                  point.x = this.left; else if (point.x > this.right)                  point.x = this.left;
160    else if (point.x > this.right)
161                  point.x = this.right;                  point.x = this.right;
162          };          };
163    
# Line 550  var jg; Line 545  var jg;
545    
546          E.prototype.remove = function () {          E.prototype.remove = function () {
547              if (this.parent)              if (this.parent)
548                  this.parent.removeChild(this); else                  this.parent.removeChild(this);
549    else
550                  throw "Can not remove layer. (use scene.deleteLayer)";                  throw "Can not remove layer. (use scene.deleteLayer)";
551          };          };
552    
# Line 608  var jg; Line 604  var jg;
604                  return;                  return;
605              this.started = true;              this.started = true;
606              if (this.scene)              if (this.scene)
607                  this.scene.game.update.handle(this, this.update); else                  this.scene.game.update.handle(this, this.update);
608    else
609                  this.addActiveQueue(function () {                  this.addActiveQueue(function () {
610                      this.scene.game.update.handle(this, this.update);                      this.scene.game.update.handle(this, this.update);
611                  });                  });
# Line 619  var jg; Line 616  var jg;
616                  return;                  return;
617              this.started = false;              this.started = false;
618              if (this.scene)              if (this.scene)
619                  this.scene.game.update.remove(this, this.update); else                  this.scene.game.update.remove(this, this.update);
620    else
621                  this.addActiveQueue(function () {                  this.addActiveQueue(function () {
622                      this.scene.game.update.remove(this, this.update);                      this.scene.game.update.remove(this, this.update);
623                  });                  });
# Line 627  var jg; Line 625  var jg;
625    
626          E.prototype.startTimer = function (wait, method) {          E.prototype.startTimer = function (wait, method) {
627              if (this.scene)              if (this.scene)
628                  this.scene.game.addTimer(wait, this, method ? method : this.interval); else                  this.scene.game.addTimer(wait, this, method ? method : this.interval);
629    else
630                  this.addActiveQueue(function () {                  this.addActiveQueue(function () {
631                      this.scene.game.addTimer(wait, this, method ? method : this.interval);                      this.scene.game.addTimer(wait, this, method ? method : this.interval);
632                  });                  });
# Line 635  var jg; Line 634  var jg;
634    
635          E.prototype.stopTimer = function (wait, method) {          E.prototype.stopTimer = function (wait, method) {
636              if (this.scene)              if (this.scene)
637                  this.scene.game.removeTimer(wait, this, method ? method : this.interval); else                  this.scene.game.removeTimer(wait, this, method ? method : this.interval);
638    else
639                  this.addActiveQueue(function () {                  this.addActiveQueue(function () {
640                      this.scene.game.removeTimer(wait, this, method ? method : this.interval);                      this.scene.game.removeTimer(wait, this, method ? method : this.interval);
641                  });                  });
# Line 798  var jg; Line 798  var jg;
798          Shape.prototype.setClip = function (value) {          Shape.prototype.setClip = function (value) {
799              this.clip = value;              this.clip = value;
800              if (this.clip)              if (this.clip)
801                  this.disableTransform = true; else                  this.disableTransform = true;
802    else
803                  delete this.disableTransform;                  delete this.disableTransform;
804          };          };
805    
# Line 817  var jg; Line 818  var jg;
818    
819          Shape.prototype.setColor = function (color) {          Shape.prototype.setColor = function (color) {
820              if (this.style == jg.ShapeStyle.Stroke)              if (this.style == jg.ShapeStyle.Stroke)
821                  this.setDrawOption("strokeStyle", color); else                  this.setDrawOption("strokeStyle", color);
822    else
823                  this.setDrawOption("fillStyle", color);                  this.setDrawOption("fillStyle", color);
824          };          };
825    
826          Shape.prototype.getColor = function () {          Shape.prototype.getColor = function () {
827              if (this.style == jg.ShapeStyle.Stroke)              if (this.style == jg.ShapeStyle.Stroke)
828                  return this.getDrawOption("strokeStyle"); else                  return this.getDrawOption("strokeStyle");
829    else
830                  return this.getDrawOption("filltyle");                  return this.getDrawOption("filltyle");
831          };          };
832    
# Line 856  var jg; Line 859  var jg;
859                  context.restore();                  context.restore();
860                  context.clip();                  context.clip();
861              } else if (this.style == jg.ShapeStyle.Fill)              } else if (this.style == jg.ShapeStyle.Fill)
862                  context.fill(); else                  context.fill();
863    else
864                  context.stroke();                  context.stroke();
865          };          };
866          Shape.PI_200_PER = Math.PI * 2;          Shape.PI_200_PER = Math.PI * 2;
# Line 872  var jg; Line 876  var jg;
876          }          }
877          Trigger.prototype.handleInsert = function (index, owner, handler) {          Trigger.prototype.handleInsert = function (index, owner, handler) {
878              if (!handler)              if (!handler)
879                  this.handlers.splice(index, 0, { owner: window, handler: owner }); else                  this.handlers.splice(index, 0, { owner: window, handler: owner });
880    else
881                  this.handlers.splice(index, 0, { owner: owner, handler: handler });                  this.handlers.splice(index, 0, { owner: owner, handler: handler });
882          };          };
883    
884          Trigger.prototype.handle = function (owner, handler) {          Trigger.prototype.handle = function (owner, handler) {
885              if (!handler)              if (!handler)
886                  this.handlers.push({ owner: window, handler: owner }); else                  this.handlers.push({ owner: window, handler: owner });
887    else
888                  this.handlers.push({ owner: owner, handler: handler });                  this.handlers.push({ owner: owner, handler: handler });
889          };          };
890    
# Line 1043  var jg; Line 1049  var jg;
1049    
1050          ImageResourceLoader.prototype.completed = function (name, image, is_success) {          ImageResourceLoader.prototype.completed = function (name, image, is_success) {
1051              if (!is_success)              if (!is_success)
1052                  console.log("error: " + name); else                  console.log("error: " + name);
1053    else
1054                  this.resource.images[name] = image;                  this.resource.images[name] = image;
1055    
1056              this.resource.requestCompleted(name);              this.resource.requestCompleted(name);
# Line 1087  var jg; Line 1094  var jg;
1094    
1095          ScriptResourceLoader.prototype.completed = function (name, script, is_success) {          ScriptResourceLoader.prototype.completed = function (name, script, is_success) {
1096              if (!is_success)              if (!is_success)
1097                  console.log("error: " + name); else                  console.log("error: " + name);
1098    else
1099                  this.resource.scripts[name] = script;                  this.resource.scripts[name] = script;
1100    
1101              this.resource.requestCompleted(name);              this.resource.requestCompleted(name);
# Line 1118  var jg; Line 1126  var jg;
1126    
1127          SoundResourceLoader.prototype.completed = function (name, audio, is_success) {          SoundResourceLoader.prototype.completed = function (name, audio, is_success) {
1128              if (!is_success)              if (!is_success)
1129                  console.log("error: " + name); else                  console.log("error: " + name);
1130    else
1131                  this.resource.sounds[name] = audio;                  this.resource.sounds[name] = audio;
1132    
1133              this.resource.requestCompleted(name);              this.resource.requestCompleted(name);
# Line 1185  var jg; Line 1194  var jg;
1194              var dot = url.split(/\./g);              var dot = url.split(/\./g);
1195              var ext;              var ext;
1196              if (dot.length == 0)              if (dot.length == 0)
1197                  ext = ""; else                  ext = "";
1198    else
1199                  ext = dot[dot.length - 1];                  ext = dot[dot.length - 1];
1200    
1201              ext = ext.toLowerCase();              ext = ext.toLowerCase();
# Line 1283  var jg; Line 1293  var jg;
1293    
1294              var linkMode = this.currentMode();              var linkMode = this.currentMode();
1295              if (newMode !== undefined && newMode != newMode)              if (newMode !== undefined && newMode != newMode)
1296                  this.changeMode(newMode); else if (linkMode && this[linkMode + "Show"])                  this.changeMode(newMode);
1297    else if (linkMode && this[linkMode + "Show"])
1298                  this[linkMode + "Show"]();                  this[linkMode + "Show"]();
1299          };          };
1300    
# Line 1363  var jg; Line 1374  var jg;
1374    
1375          Scene.prototype.append = function (entity, layerName) {          Scene.prototype.append = function (entity, layerName) {
1376              if (!layerName)              if (!layerName)
1377                  this.root.append(entity); else                  this.root.append(entity);
1378    else
1379                  this.layers[layerName].append(entity);                  this.layers[layerName].append(entity);
1380          };          };
1381    
# Line 1745  var jg; Line 1757  var jg;
1757              if (this.syncObj) {              if (this.syncObj) {
1758                  var val;                  var val;
1759                  if (typeof this.syncObj[this.syncProp] == "function")                  if (typeof this.syncObj[this.syncProp] == "function")
1760                      val = this.syncObj[this.syncProp](this); else                      val = this.syncObj[this.syncProp](this);
1761    else
1762                      val = this.syncObj[this.syncProp];                      val = this.syncObj[this.syncProp];
1763    
1764                  this.text = this.syncRound ? Math.round(val) : val;                  this.text = this.syncRound ? Math.round(val) : val;
# Line 1812  var jg; Line 1825  var jg;
1825              this.width = size.width;              this.width = size.width;
1826              this.height = size.height;              this.height = size.height;
1827              if (offset)              if (offset)
1828                  this.moveTo(offset.x, offset.y); else                  this.moveTo(offset.x, offset.y);
1829    else
1830                  this.moveTo(0, 0);                  this.moveTo(0, 0);
1831    
1832              this.defaultStyle = "#000";              this.defaultStyle = "#000";
# Line 1878  var jg; Line 1892  var jg;
1892              this.lines = [];              this.lines = [];
1893    
1894              if (this.bufferBg)              if (this.bufferBg)
1895                  c.putImageData(this.bufferBg, 0, 0); else                  c.putImageData(this.bufferBg, 0, 0);
1896    else
1897                  c.clearRect(0, 0, this.width, this.height);                  c.clearRect(0, 0, this.width, this.height);
1898    
1899              c.fillStyle = this.defaultStyle;              c.fillStyle = this.defaultStyle;
# Line 1944  var jg; Line 1959  var jg;
1959              this.sprite = new jg.Sprite(this.buffer);              this.sprite = new jg.Sprite(this.buffer);
1960              this.sprite.moveTo(0, 0);              this.sprite.moveTo(0, 0);
1961              if (this.entities.length == 1)              if (this.entities.length == 1)
1962                  this.entities.push(this.sprite); else                  this.entities.push(this.sprite);
1963    else
1964                  this.entities[1] = this.sprite;                  this.entities[1] = this.sprite;
1965    
1966              return offset == len ? -1 : offset;              return offset == len ? -1 : offset;
# Line 2478  var jg; Line 2494  var jg;
2494    
2495          Renderer.prototype.renderParent = function (parent, c) {          Renderer.prototype.renderParent = function (parent, c) {
2496              if (parent.orderDraw)              if (parent.orderDraw)
2497                  parent.orderDraw();                  parent.orderDraw(parent);
2498    
2499              c.save();              c.save();
2500              if (parent.opacity != 1)              if (parent.opacity != 1)
# Line 2553  var jg; Line 2569  var jg;
2569          Renderer.prototype.useDrawOption = function (entity, c) {          Renderer.prototype.useDrawOption = function (entity, c) {
2570              for (var p in entity.options) {              for (var p in entity.options) {
2571                  if (this.drawOptionFunctions[p])                  if (this.drawOptionFunctions[p])
2572                      this.drawOptionFunctions[p].call(this, c, entity, entity.options[p]); else {                      this.drawOptionFunctions[p].call(this, c, entity, entity.options[p]);
2573    else {
2574                      c[p] = entity.options[p];                      c[p] = entity.options[p];
2575                  }                  }
2576              }              }
# Line 2874  var jg; Line 2891  var jg;
2891              var container, transferMode;              var container, transferMode;
2892              for (var i = 2; i < arguments.length; i++) {              for (var i = 2; i < arguments.length; i++) {
2893                  if (arguments[i] instanceof HTMLElement)                  if (arguments[i] instanceof HTMLElement)
2894                      container = arguments[i]; else if (typeof arguments[i] == "string") {                      container = arguments[i];
2895    else if (typeof arguments[i] == "string") {
2896                      this.renderer = new window[arguments[i]](this, container, transferMode);                      this.renderer = new window[arguments[i]](this, container, transferMode);
2897                      this.renderer.changeScene(this.scene);                      this.renderer.changeScene(this.scene);
2898                  } else                  } else
# Line 3228  var jg; Line 3246  var jg;
3246          Game.prototype.setLoadingScene = function (scene) {          Game.prototype.setLoadingScene = function (scene) {
3247              if (!this.loadingScene) {              if (!this.loadingScene) {
3248                  if (scene instanceof jg.LoadingScene)                  if (scene instanceof jg.LoadingScene)
3249                      this.loadingScene = scene; else                      this.loadingScene = scene;
3250    else
3251                      this.loadingScene = new scene(this, this.resource);                      this.loadingScene = new scene(this, this.resource);
3252    
3253                  this.loadingScene.finished.handle(this, this.preloadComplete);                  this.loadingScene.finished.handle(this, this.preloadComplete);
# Line 3287  var jg; Line 3306  var jg;
3306                      this[n].fire(e);                      this[n].fire(e);
3307                  } else {                  } else {
3308                      if (e.action == jg.InputEventAction.Down)                      if (e.action == jg.InputEventAction.Down)
3309                          this.setPointingEntity(e); else if (!this.dragParam)                          this.setPointingEntity(e);
3310                          continue; else  else if (!this.dragParam)
3311                            continue;
3312    else
3313                          (e).set(this.dragParam.entity);                          (e).set(this.dragParam.entity);
3314    
3315                      if ((e).entity && (e).entity[n])                      if ((e).entity && (e).entity[n])
# Line 3354  var jg; Line 3375  var jg;
3375          Game.prototype.fullscreen = function () {          Game.prototype.fullscreen = function () {
3376              var t = this.renderer.container;              var t = this.renderer.container;
3377              if (t["requestFullScreen"])              if (t["requestFullScreen"])
3378                  t["requestFullScreen"](); else if (t["webkitRequestFullScreen"])                  t["requestFullScreen"]();
3379                  t["webkitRequestFullScreen"](); else if (t["mozRequestFullScreen"])  else if (t["webkitRequestFullScreen"])
3380                  t["mozRequestFullScreen"](); else                  t["webkitRequestFullScreen"]();
3381    else if (t["mozRequestFullScreen"])
3382                    t["mozRequestFullScreen"]();
3383    else
3384                  return false;                  return false;
3385              return true;              return true;
3386          };          };
# Line 3364  var jg; Line 3388  var jg;
3388          Game.prototype.exitFullscreen = function () {          Game.prototype.exitFullscreen = function () {
3389              var t = this.renderer.container;              var t = this.renderer.container;
3390              if (t["exitFullscreen"])              if (t["exitFullscreen"])
3391                  t["exitFullscreen"](); else if (t["webkitCancelFullScreen"])                  t["exitFullscreen"]();
3392                  t["webkitCancelFullScreen"](); else if (t["mozCancelFullScreen"])  else if (t["webkitCancelFullScreen"])
3393                  t["mozCancelFullScreen"](); else                  t["webkitCancelFullScreen"]();
3394    else if (t["mozCancelFullScreen"])
3395                    t["mozCancelFullScreen"]();
3396    else
3397                  return false;                  return false;
3398              return true;              return true;
3399          };          };
# Line 3520  var jg; Line 3547  var jg;
3547    
3548              Filter.prototype.checkRGBBoundary = function (val) {              Filter.prototype.checkRGBBoundary = function (val) {
3549                  if (val < 0)                  if (val < 0)
3550                      return 0; else if (val > 255)                      return 0;
3551    else if (val > 255)
3552                      return 255;                      return 255;
3553    
3554                  return val;                  return val;
# Line 3572  var jg; Line 3600  var jg;
3600                  var enableCount = 0;                  var enableCount = 0;
3601                  for (var i = 0, len = a.length; i < len; i += 4) {                  for (var i = 0, len = a.length; i < len; i += 4) {
3602                      if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2] && a[i + 3] == b[i + 3])                      if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2] && a[i + 3] == b[i + 3])
3603                          mask[i] = 1; else                          mask[i] = 1;
3604    else
3605                          mask[i] = 0;                          mask[i] = 0;
3606                  }                  }
3607                  this.mask = mask;                  this.mask = mask;
# Line 3992  var jg; Line 4021  var jg;
4021    
4022          (function (NoiseType) {          (function (NoiseType) {
4023              NoiseType[NoiseType["Mono"] = 0] = "Mono";              NoiseType[NoiseType["Mono"] = 0] = "Mono";
   
4024              NoiseType[NoiseType["Color"] = 1] = "Color";              NoiseType[NoiseType["Color"] = 1] = "Color";
4025          })(ImageFilter.NoiseType || (ImageFilter.NoiseType = {}));          })(ImageFilter.NoiseType || (ImageFilter.NoiseType = {}));
4026          var NoiseType = ImageFilter.NoiseType;          var NoiseType = ImageFilter.NoiseType;
# Line 4251  var jg; Line 4279  var jg;
4279                      this.old[prop] = {};                      this.old[prop] = {};
4280                      for (var j in this.props[prop]) {                      for (var j in this.props[prop]) {
4281                          if (typeof this.props[prop][j] === "function")                          if (typeof this.props[prop][j] === "function")
4282                              this.target[prop][j] = this.props[prop][j].call(this.entity); else                              this.target[prop][j] = this.props[prop][j].call(this.entity);
4283    else
4284                              this.target[prop][j] = this.props[prop][j];                              this.target[prop][j] = this.props[prop][j];
4285                          this.origin[prop][j] = this.entity[prop][j];                          this.origin[prop][j] = this.entity[prop][j];
4286                          this.old[prop][j] = this.entity[prop][j];                          this.old[prop][j] = this.entity[prop][j];
# Line 4261  var jg; Line 4290  var jg;
4290                  }                  }
4291    
4292                  if (typeof this.props[prop] === "function")                  if (typeof this.props[prop] === "function")
4293                      this.target[prop] = this.props[prop].call(this.entity); else                      this.target[prop] = this.props[prop].call(this.entity);
4294    else
4295                      this.target[prop] = this.props[prop];                      this.target[prop] = this.props[prop];
4296    
4297                  if (jg.TWEEN_DRAW_OPTION_SETTERS[prop])                  if (jg.TWEEN_DRAW_OPTION_SETTERS[prop])
4298                      this.origin[prop] = this.entity.getDrawOption(prop); else                      this.origin[prop] = this.entity.getDrawOption(prop);
4299    else
4300                      this.origin[prop] = this.entity[prop];                      this.origin[prop] = this.entity[prop];
4301    
4302                  this.old[prop] = this.origin[prop];                  this.old[prop] = this.origin[prop];
# Line 4363  var jg; Line 4394  var jg;
4394              if (force || this._activated) {              if (force || this._activated) {
4395                  this._activated = false;                  this._activated = false;
4396                  if (this.entity.scene)                  if (this.entity.scene)
4397                      this.entity.scene.game.update.remove(this, this.tick); else                      this.entity.scene.game.update.remove(this, this.tick);
4398    else
4399                      this.entity.addActiveQueue(function () {                      this.entity.addActiveQueue(function () {
4400                          _this.entity.scene.game.update.remove(_this, _this.tick);                          _this.entity.scene.game.update.remove(_this, _this.tick);
4401                      });                      });
# Line 4374  var jg; Line 4406  var jg;
4406              var _this = this;              var _this = this;
4407              if (force || (!this._activated && !this.paused)) {              if (force || (!this._activated && !this.paused)) {
4408                  if (this.entity.scene)                  if (this.entity.scene)
4409                      this.entity.scene.game.update.handle(this, this.tick); else                      this.entity.scene.game.update.handle(this, this.tick);
4410    else
4411                      this.entity.addActiveQueue(function () {                      this.entity.addActiveQueue(function () {
4412                          _this.entity.scene.game.update.handle(_this, _this.tick);                          _this.entity.scene.game.update.handle(_this, _this.tick);
4413                      });                      });
# Line 4854  var jg; Line 4887  var jg;
4887              for (var _i = 0; _i < (arguments.length - 0); _i++) {              for (var _i = 0; _i < (arguments.length - 0); _i++) {
4888                  games[_i] = arguments[_i + 0];                  games[_i] = arguments[_i + 0];
4889              }              }
             var _this = this;  
4890              games.forEach(function (game) {              games.forEach(function (game) {
4891                  game.renderer.handler.addEventListener("focus", JGUtil.proxy(function () {                  game.renderer.handler.addEventListener("focus", JGUtil.proxy(function () {
4892                      this.resume();                      this.resume();
# Line 4869  var jg; Line 4901  var jg;
4901                          game.loaded.remove(this, initEnd);                          game.loaded.remove(this, initEnd);
4902                      };                      };
4903                      if (game.scene instanceof jg.LoadingScene)                      if (game.scene instanceof jg.LoadingScene)
4904                          game.loaded.handle(game, initEnd); else                          game.loaded.handle(game, initEnd);
4905    else
4906                          initEnd.call(game);                          initEnd.call(game);
4907                  }                  }
4908              });              });
# Line 4940  var jg; Line 4973  var jg;
4973              if (maxMove) {              if (maxMove) {
4974                  if (absx > maxMove || absy > maxMove) {                  if (absx > maxMove || absy > maxMove) {
4975                      if (ret.x < 0)                      if (ret.x < 0)
4976                          ret.x = -maxMove * xper; else                          ret.x = -maxMove * xper;
4977    else
4978                          ret.x = maxMove * xper;                          ret.x = maxMove * xper;
4979                      if (ret.y < 0)                      if (ret.y < 0)
4980                          ret.y = -maxMove * yper; else                          ret.y = -maxMove * yper;
4981    else
4982                          ret.y = maxMove * yper;                          ret.y = maxMove * yper;
4983                  }                  }
4984              }              }
# Line 4960  var jg; Line 4995  var jg;
4995                  return null;                  return null;
4996    
4997              if (xp > yp)              if (xp > yp)
4998                  return (_p1.x > _p2.x) ? jg.Angle.Left : jg.Angle.Right; else                  return (_p1.x > _p2.x) ? jg.Angle.Left : jg.Angle.Right;
4999    else
5000                  return (_p1.y > _p2.y) ? jg.Angle.Up : jg.Angle.Down;                  return (_p1.y > _p2.y) ? jg.Angle.Up : jg.Angle.Down;
5001          };          };
5002    
# Line 4974  var jg; Line 5010  var jg;
5010                  return null;                  return null;
5011    
5012              if (xp > yp)              if (xp > yp)
5013                  return (_p1.x > _p2.x) ? jg.Keytype.Left : jg.Keytype.Right; else                  return (_p1.x > _p2.x) ? jg.Keytype.Left : jg.Keytype.Right;
5014    else
5015                  return (_p1.y > _p2.y) ? jg.Keytype.Up : jg.Keytype.Down;                  return (_p1.y > _p2.y) ? jg.Keytype.Up : jg.Keytype.Down;
5016          };          };
5017    
# Line 5033  var jg; Line 5070  var jg;
5070              if (p1.x > p.x) {              if (p1.x > p.x) {
5071                  p1.x -= speed * t;                  p1.x -= speed * t;
5072                  if (p1.x < p.x)                  if (p1.x < p.x)
5073                      p1.x = p.x; else                      p1.x = p.x;
5074    else
5075                      xng = true;                      xng = true;
5076              } else if (p1.x < p.x) {              } else if (p1.x < p.x) {
5077                  p1.x += speed * t;                  p1.x += speed * t;
5078                  if (p1.x > p.x)                  if (p1.x > p.x)
5079                      p1.x = p.x; else                      p1.x = p.x;
5080    else
5081                      xng = true;                      xng = true;
5082              }              }
5083    
5084              if (p1.y > p.y) {              if (p1.y > p.y) {
5085                  p1.y -= speed * t;                  p1.y -= speed * t;
5086                  if (p1.y < p.y)                  if (p1.y < p.y)
5087                      p1.y = p.y; else                      p1.y = p.y;
5088    else
5089                      yng = true;                      yng = true;
5090              } else if (p1.y < p.y) {              } else if (p1.y < p.y) {
5091                  p1.y += speed * t;                  p1.y += speed * t;
5092                  if (p1.y > p.y)                  if (p1.y > p.y)
5093                      p1.y = p.y; else                      p1.y = p.y;
5094    else
5095                      yng = true;                      yng = true;
5096              }              }
5097    
5098              return xng || yng ? false : true;              return xng || yng ? false : true;
5099          };          };
5100    
5101          JGUtil.orderDrawY = function () {          JGUtil.orderDrawY = function (target) {
5102              var e = this.entities, len = e.length;              var e = target.entities, len = e.length;
5103              for (var i = 1; i < len; i++) {              for (var i = 1; i < len; i++) {
5104                  for (var j = i; j > 0; j--) {                  for (var j = i; j > 0; j--) {
5105                      if (e[j].y >= e[j - 1].y)                      if (e[j].y >= e[j - 1].y)
# Line 5160  var jg; Line 5201  var jg;
5201              }              }
5202    
5203              if (ret.chrome)              if (ret.chrome)
5204                  ret.webkit = true; else if (ret.webkit)                  ret.webkit = true;
5205    else if (ret.webkit)
5206                  ret.safari = true;                  ret.safari = true;
5207    
5208              JGUtil.browser = ret;              JGUtil.browser = ret;
# Line 5170  var jg; Line 5212  var jg;
5212    
5213          JGUtil.setCrispEdges = function (game, crispEdges) {          JGUtil.setCrispEdges = function (game, crispEdges) {
5214              if (crispEdges)              if (crispEdges)
5215                  window["imageSmoothingEnabled"] = crispEdges; else                  window["imageSmoothingEnabled"] = crispEdges;
5216    else
5217                  delete window["imageSmoothingEnabled"];                  delete window["imageSmoothingEnabled"];
5218              game.refresh();              game.refresh();
5219          };          };
# Line 5269  var jg; Line 5312  var jg;
5312          Line.prototype.setClip = function (value) {          Line.prototype.setClip = function (value) {
5313              this.clip = value;              this.clip = value;
5314              if (this.clip)              if (this.clip)
5315                  this.disableTransform = true; else                  this.disableTransform = true;
5316    else
5317                  delete this.disableTransform;                  delete this.disableTransform;
5318          };          };
5319    
# Line 5280  var jg; Line 5324  var jg;
5324                  var x = this.p[0].x + this.p[i].x;                  var x = this.p[0].x + this.p[i].x;
5325                  var y = this.p[0].y + this.p[i].y;                  var y = this.p[0].y + this.p[i].y;
5326                  if (min.x > x)                  if (min.x > x)
5327                      min.x = x; else if (max.x < x)                      min.x = x;
5328    else if (max.x < x)
5329                      max.x = x;                      max.x = x;
5330                  if (min.y > y)                  if (min.y > y)
5331                      min.y = y; else if (max.y < y)                      min.y = y;
5332    else if (max.y < y)
5333                      max.y = y;                      max.y = y;
5334              }              }
5335              this.width = max.x - min.x;              this.width = max.x - min.x;
# Line 5746  var jg; Line 5792  var jg;
5792              }              }
5793    
5794              if (rotate)              if (rotate)
5795                  sp.tl().resizeTo(this.game.width * 2, this.game.height * 2, t).and().moveTo(-this.game.width / 2, -this.game.height / 2, t); else                  sp.tl().resizeTo(this.game.width * 2, this.game.height * 2, t).and().moveTo(-this.game.width / 2, -this.game.height / 2, t);
5796    else
5797                  sp.tl().resizeTo(this.game.width, this.game.height, t).and().moveTo(0, 0, t);                  sp.tl().resizeTo(this.game.width, this.game.height, t).and().moveTo(0, 0, t);
5798              sp.tl().then(function () {              sp.tl().then(function () {
5799                  _this.effected.fire();                  _this.effected.fire();
# Line 5920  var jg; Line 5967  var jg;
5967    
5968          UIWindow.prototype.createBgImage = function (e, srcPadding, buf) {          UIWindow.prototype.createBgImage = function (e, srcPadding, buf) {
5969              if (!buf)              if (!buf)
5970                  var buf = new jg.BufferedRenderer(e);                  var buf = new BufferedRenderer(e);
5971              if (srcPadding === undefined)              if (srcPadding === undefined)
5972                  srcPadding = this.padding;                  srcPadding = this.padding;
5973              buf.renderUnit(e);              buf.renderUnit(e);
# Line 6112  var jg; Line 6159  var jg;
6159    
6160          MessageWindow.prototype.hide = function (fade) {          MessageWindow.prototype.hide = function (fade) {
6161              if (fade)              if (fade)
6162                  this.tl().fadeOut(200); else                  this.tl().fadeOut(200);
6163    else
6164                  _super.prototype.hide.call(this);                  _super.prototype.hide.call(this);
6165          };          };
6166    
6167          MessageWindow.prototype.show = function (fade) {          MessageWindow.prototype.show = function (fade) {
6168              if (fade)              if (fade)
6169                  this.tl().fadeIn(200); else                  this.tl().fadeIn(200);
6170    else
6171                  _super.prototype.show.call(this);                  _super.prototype.show.call(this);
6172          };          };
6173    
# Line 6201  var jg; Line 6250  var jg;
6250                      image = sprite.image;                      image = sprite.image;
6251                  }                  }
6252                  if (scale)                  if (scale)
6253                      context.drawImage(image, 0, 0, width, height); else                      context.drawImage(image, 0, 0, width, height);
6254    else
6255                      context.drawImage(image, 0, 0);                      context.drawImage(image, 0, 0);
6256              }              }
6257              this.imageData = context.getImageData(0, 0, this.width, this.height);              this.imageData = context.getImageData(0, 0, this.width, this.height);

Legend:
Removed from v.150  
changed lines
  Added in v.151

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