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 48 by tsugehara, Tue Mar 5 12:19:40 2013 UTC revision 51 by tsugehara, Tue Mar 5 14:57:21 2013 UTC
# Line 2118  var Game = (function () { Line 2118  var Game = (function () {
2118          this.keyDown = new Trigger();          this.keyDown = new Trigger();
2119          this.keyUp = new Trigger();          this.keyUp = new Trigger();
2120          this.timers = new Array();          this.timers = new Array();
2121          this.currentScene = new Scene(this);          this.scene = new Scene(this);
2122          this.scenes = new Array();          this.scenes = new Array();
2123          this.scenes.push(this.currentScene);          this.scenes.push(this.scene);
2124          this.resource = Resource.getInstance();          this.resource = Resource.getInstance();
2125          var container, transferMode;          var container, transferMode;
2126          for(var i = 2; i < arguments.length; i++) {          for(var i = 2; i < arguments.length; i++) {
# Line 2128  var Game = (function () { Line 2128  var Game = (function () {
2128                  container = arguments[i];                  container = arguments[i];
2129              } else if(typeof arguments[i] == "string") {              } else if(typeof arguments[i] == "string") {
2130                  this.renderer = new window[arguments[i]](this, container, transferMode);                  this.renderer = new window[arguments[i]](this, container, transferMode);
2131                  this.renderer.changeScene(this.currentScene);                  this.renderer.changeScene(this.scene);
2132              } else {              } else {
2133                  transferMode = arguments[i];                  transferMode = arguments[i];
2134              }              }
2135          }          }
2136          if(!this.renderer) {          if(!this.renderer) {
2137              this.renderer = new GameRenderer(this, container, transferMode);              this.renderer = new GameRenderer(this, container, transferMode);
2138              this.renderer.changeScene(this.currentScene);              this.renderer.changeScene(this.scene);
2139          }          }
2140          this.keyboardHandler();          this.keyboardHandler();
2141          this.pointHandler();          this.pointHandler();
# Line 2215  var Game = (function () { Line 2215  var Game = (function () {
2215          var _this = this;          var _this = this;
2216          var dragParam = null;          var dragParam = null;
2217          this.onmousedown = function (e) {          this.onmousedown = function (e) {
2218              var layers = _this.currentScene.getLayerArray();              var layers = _this.scene.getLayerArray();
2219              var layer;              var layer;
2220              var offset = {              var offset = {
2221                  x: _this.scale ? e.offsetX / _this.scale : e.offsetX,                  x: _this.scale ? e.offsetX / _this.scale : e.offsetX,
# Line 2231  var Game = (function () { Line 2231  var Game = (function () {
2231                  }                  }
2232                  dragParam = new InputPointEvent(e, dragObj, _this.scale);                  dragParam = new InputPointEvent(e, dragObj, _this.scale);
2233                  _this.pointDown.fire(dragParam);                  _this.pointDown.fire(dragParam);
2234                  if(_this.currentScene.pointDown) {                  if(_this.scene.pointDown) {
2235                      _this.currentScene.pointDown.fire(dragParam);                      _this.scene.pointDown.fire(dragParam);
2236                  }                  }
2237                  if(dragObj.pointDown) {                  if(dragObj.pointDown) {
2238                      dragObj.pointDown.fire(dragParam);                      dragObj.pointDown.fire(dragParam);
# Line 2249  var Game = (function () { Line 2249  var Game = (function () {
2249              if(dragParam.entity.pointMove) {              if(dragParam.entity.pointMove) {
2250                  dragParam.entity.pointMove.fire(param);                  dragParam.entity.pointMove.fire(param);
2251              }              }
2252              if(_this.currentScene.pointMove) {              if(_this.scene.pointMove) {
2253                  _this.currentScene.pointMove.fire(param);                  _this.scene.pointMove.fire(param);
2254              }              }
2255              _this.pointMove.fire(param);              _this.pointMove.fire(param);
2256              e.preventDefault();              e.preventDefault();
# Line 2263  var Game = (function () { Line 2263  var Game = (function () {
2263              if(dragParam.entity.pointUp) {              if(dragParam.entity.pointUp) {
2264                  dragParam.entity.pointUp.fire(param);                  dragParam.entity.pointUp.fire(param);
2265              }              }
2266              if(_this.currentScene.pointUp) {              if(_this.scene.pointUp) {
2267                  _this.currentScene.pointUp.fire(param);                  _this.scene.pointUp.fire(param);
2268              }              }
2269              _this.pointUp.fire(param);              _this.pointUp.fire(param);
2270              dragParam = null;              dragParam = null;
# Line 2305  var Game = (function () { Line 2305  var Game = (function () {
2305          var onkeydown = function (e) {          var onkeydown = function (e) {
2306              var keyParam = new InputKeyboardEvent(_this.keymap[e.keyCode], e);              var keyParam = new InputKeyboardEvent(_this.keymap[e.keyCode], e);
2307              _this.keyDown.fire(keyParam);              _this.keyDown.fire(keyParam);
2308              if(_this.currentScene.keyDown) {              if(_this.scene.keyDown) {
2309                  _this.currentScene.keyDown.fire(keyParam);                  _this.scene.keyDown.fire(keyParam);
2310              }              }
2311              if(_this.keymap[e.keyCode] != undefined) {              if(_this.keymap[e.keyCode] != undefined) {
2312                  e.preventDefault();                  e.preventDefault();
# Line 2315  var Game = (function () { Line 2315  var Game = (function () {
2315          var onkeyup = function (e) {          var onkeyup = function (e) {
2316              var keyParam = new InputKeyboardEvent(_this.keymap[e.keyCode], e);              var keyParam = new InputKeyboardEvent(_this.keymap[e.keyCode], e);
2317              _this.keyUp.fire(keyParam);              _this.keyUp.fire(keyParam);
2318              if(_this.currentScene.keyUp) {              if(_this.scene.keyUp) {
2319                  _this.currentScene.keyUp.fire(keyParam);                  _this.scene.keyUp.fire(keyParam);
2320              }              }
2321              if(_this.keymap[e.keyCode] != undefined) {              if(_this.keymap[e.keyCode] != undefined) {
2322                  e.preventDefault();                  e.preventDefault();
# Line 2368  var Game = (function () { Line 2368  var Game = (function () {
2368      Game.prototype.changeScene = function (scene, effect, endOldScene) {      Game.prototype.changeScene = function (scene, effect, endOldScene) {
2369          var _this = this;          var _this = this;
2370          if(effect) {          if(effect) {
2371              var currentScene = this.currentScene;              var currentScene = this.scene;
2372              Effect.sceneEffect(this, currentScene, scene, effect, function () {              Effect.sceneEffect(this, currentScene, scene, effect, function () {
2373                  _this.endScene();                  _this.endScene();
2374                  _this.changeScene(scene);                  _this.changeScene(scene);
# Line 2377  var Game = (function () { Line 2377  var Game = (function () {
2377          }          }
2378          this.scenes.push(scene);          this.scenes.push(scene);
2379          scene.game = this;          scene.game = this;
2380          this.currentScene.hid.fire();          this.scene.hid.fire();
2381          this.currentScene = scene;          this.scene = scene;
2382          this.renderer.changeScene(this.currentScene);          this.renderer.changeScene(this.scene);
2383          this.currentScene.started.fire();          this.scene.started.fire();
2384      };      };
2385      Game.prototype.endScene = function (effect) {      Game.prototype.endScene = function (effect) {
2386          var _this = this;          var _this = this;
# Line 2389  var Game = (function () { Line 2389  var Game = (function () {
2389              return;              return;
2390          }          }
2391          if(effect) {          if(effect) {
2392              Effect.sceneEffect(this, this.currentScene, this.scenes[this.scenes.length - 2], effect, function () {              Effect.sceneEffect(this, this.scene, this.scenes[this.scenes.length - 2], effect, function () {
2393                  _this.endScene();                  _this.endScene();
2394              }, true);              }, true);
2395              return;              return;
2396          }          }
2397          this.currentScene.destroy();          this.scene.destroy();
2398          this.scenes.pop();          this.scenes.pop();
2399          this.currentScene.ended.fire();          this.scene.ended.fire();
2400          this.currentScene = this.scenes[this.scenes.length - 1];          this.scene = this.scenes[this.scenes.length - 1];
2401          this.renderer.changeScene(this.currentScene);          this.renderer.changeScene(this.scene);
2402          this.currentScene.showed.fire();          this.scene.showed.fire();
2403      };      };
2404      Game.prototype.r = function (name) {      Game.prototype.r = function (name) {
2405          return this.resource.get(name);          return this.resource.get(name);
# Line 2437  var Game = (function () { Line 2437  var Game = (function () {
2437          this.changeScene(loadingScene);          this.changeScene(loadingScene);
2438      };      };
2439      Game.prototype.preloadOther = function (identity) {      Game.prototype.preloadOther = function (identity) {
2440          var loadingScene = this.currentScene;          var loadingScene = this.scene;
2441          loadingScene.addOtherResource(identity);          loadingScene.addOtherResource(identity);
2442      };      };
2443      Game.prototype.preloadCompleteOther = function (identity) {      Game.prototype.preloadCompleteOther = function (identity) {
2444          var loadingScene = this.currentScene;          var loadingScene = this.scene;
2445          loadingScene.otherResourceComplete(identity);          loadingScene.otherResourceComplete(identity);
2446      };      };
2447      Game.prototype.preloadComplete = function () {      Game.prototype.preloadComplete = function () {
# Line 3802  var JGUtil = (function () { Line 3802  var JGUtil = (function () {
3802              return null;              return null;
3803          }          }
3804          if(xp > yp) {          if(xp > yp) {
3805              if(_p1.x > _p2.x) {              return (_p1.x > _p2.x) ? Angle.left : Angle.right;
                 return Angle.left;  
             } else {  
                 return Angle.right;  
             }  
3806          } else {          } else {
3807              if(_p1.y > _p2.y) {              return (_p1.y > _p2.y) ? Angle.up : Angle.down;
                 return Angle.up;  
             } else {  
                 return Angle.down;  
             }  
3808          }          }
3809      };      };
3810      JGUtil.getDirectionKeytype = function getDirectionKeytype(p1, p2, minDistance) {      JGUtil.getDirectionKeytype = function getDirectionKeytype(p1, p2, minDistance) {
# Line 3824  var JGUtil = (function () { Line 3816  var JGUtil = (function () {
3816              return null;              return null;
3817          }          }
3818          if(xp > yp) {          if(xp > yp) {
3819              if(_p1.x > _p2.x) {              return (_p1.x > _p2.x) ? Keytype.left : Keytype.right;
                 return Keytype.left;  
             } else {  
                 return Keytype.right;  
             }  
3820          } else {          } else {
3821              if(_p1.y > _p2.y) {              return (_p1.y > _p2.y) ? Keytype.up : Keytype.down;
                 return Keytype.up;  
             } else {  
                 return Keytype.down;  
             }  
3822          }          }
3823      };      };
3824      JGUtil.homingX = function homingX(p1, p2, speed, t) {      JGUtil.homingX = function homingX(p1, p2, speed, t) {

Legend:
Removed from v.48  
changed lines
  Added in v.51

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