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 69 by tsugehara, Sat Mar 23 13:41:21 2013 UTC revision 70 by tsugehara, Mon Mar 25 05:39:28 2013 UTC
# Line 1147  var Resource = (function () { Line 1147  var Resource = (function () {
1147      function Resource() {      function Resource() {
1148          this.requests = [];          this.requests = [];
1149          this.loaded = new Trigger();          this.loaded = new Trigger();
1150          this.images = {          this.clear();
         };  
         this.scripts = {  
         };  
         this.sounds = {  
         };  
1151          this.loaders = {          this.loaders = {
1152          };          };
1153          this.loaders["js"] = new ScriptResourceLoader(this);          this.loaders["js"] = new ScriptResourceLoader(this);
# Line 1170  var Resource = (function () { Line 1165  var Resource = (function () {
1165              return Resource.instance;              return Resource.instance;
1166          })();          })();
1167      };      };
1168        Resource.prototype.clear = function () {
1169            this.images = {
1170            };
1171            this.scripts = {
1172            };
1173            this.sounds = {
1174            };
1175        };
1176      Resource.prototype.get = function (name) {      Resource.prototype.get = function (name) {
1177          return this.images[name];          return this.images[name];
1178      };      };
# Line 1371  var Sprite = (function (_super) { Line 1374  var Sprite = (function (_super) {
1374          this.y = 0;          this.y = 0;
1375          this.width = width;          this.width = width;
1376          this.height = height;          this.height = height;
1377            this.srcWidth = width;
1378            this.srcHeight = height;
1379          this.image = image;          this.image = image;
1380          this.sep = Math.floor(this.image.width / this.width);          this.sep = Math.floor(this.image.width / this.width);
1381          this.frame = [          this.frame = [
# Line 1379  var Sprite = (function (_super) { Line 1384  var Sprite = (function (_super) {
1384          this.fno = 0;          this.fno = 0;
1385      }      }
1386      Sprite.prototype.draw = function (context) {      Sprite.prototype.draw = function (context) {
1387          context.drawImage(this.image, (this.frame[this.fno] % this.sep) * this.width, Math.floor(this.frame[this.fno] / this.sep) * this.height, this.width, this.height, 0, 0, this.width, this.height);          context.drawImage(this.image, (this.frame[this.fno] % this.sep) * this.srcWidth, Math.floor(this.frame[this.fno] / this.sep) * this.srcHeight, this.srcWidth, this.srcHeight, 0, 0, this.width, this.height);
1388      };      };
1389      Sprite.prototype.refresh = function () {      Sprite.prototype.refresh = function () {
1390          if(this.image instanceof HTMLCanvasElement) {          if(this.image instanceof HTMLCanvasElement) {
# Line 2527  var BufferedRenderer = (function (_super Line 2532  var BufferedRenderer = (function (_super
2532      BufferedRenderer.prototype.clear = function () {      BufferedRenderer.prototype.clear = function () {
2533          this.c.clearRect(0, 0, this.size.width, this.size.height);          this.c.clearRect(0, 0, this.size.width, this.size.height);
2534      };      };
2535      BufferedRenderer.prototype.createImage = function (area, distArea) {      BufferedRenderer.prototype.createImage = function (area, distArea, canvasSize) {
2536          if(!area) {          if(!area) {
2537              area = {              area = {
2538                  x: 0,                  x: 0,
# Line 2544  var BufferedRenderer = (function (_super Line 2549  var BufferedRenderer = (function (_super
2549                  height: area.height                  height: area.height
2550              };              };
2551          }          }
2552          var canvas = window.createCanvas(area.width, area.height);          if(!canvasSize) {
2553                canvasSize = area;
2554            }
2555            var canvas = window.createCanvas(canvasSize.width, canvasSize.height);
2556          var context = canvas.getContext("2d");          var context = canvas.getContext("2d");
2557          context.drawImage(this.buffer, area.x, area.y, area.width, area.height, distArea.x, distArea.y, distArea.width, distArea.height);          context.drawImage(this.buffer, area.x, area.y, area.width, area.height, distArea.x, distArea.y, distArea.width, distArea.height);
2558          if(this.filter) {          if(this.filter) {
2559              this.applyFilter(context, area);              this.applyFilter(context, distArea);
2560          }          }
2561          return canvas;          return canvas;
2562      };      };
2563      BufferedRenderer.prototype.createSprite = function (area, distArea) {      BufferedRenderer.prototype.createSprite = function (area, distArea, canvasSize) {
2564          if(!area) {          if(!area) {
2565              area = {              area = {
2566                  x: 0,                  x: 0,
# Line 2569  var BufferedRenderer = (function (_super Line 2577  var BufferedRenderer = (function (_super
2577                  height: area.height                  height: area.height
2578              };              };
2579          }          }
2580          return new Sprite(area.width, area.height, this.createImage(area, distArea));          return new Sprite(area.width, area.height, this.createImage(area, distArea, canvasSize));
2581      };      };
2582      BufferedRenderer.prototype.applyFilter = function (c, size) {      BufferedRenderer.prototype.applyFilter = function (c, size) {
2583          var imageData = c.getImageData(0, 0, size.width, size.height);          var imageData = c.getImageData(0, 0, size.width, size.height);

Legend:
Removed from v.69  
changed lines
  Added in v.70

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