diff --git a/jaws-min.js b/jaws-min.js index ec81560..4968eb5 100644 --- a/jaws-min.js +++ b/jaws-min.js @@ -1,4 +1,4 @@ -/* Built at 2013-05-08 01:16:18 +0200 */ +/* Built at 2013-06-09 17:54:33 +0200 */ var jaws=function(c){function b(b){c.mouse_x=b.pageX||b.clientX;c.mouse_y=b.pageY||b.clientY;b=c.canvas?c.canvas:c.dom;c.mouse_x-=b.offsetLeft;c.mouse_y-=b.offsetTop}var d,e;c.title=function(b){return b?d.innerHTML=b:d.innerHTML};c.unpack=function(){"Sprite SpriteList Animation Viewport SpriteSheet Parallax TileMap Rect pressed".split(" ").forEach(function(b){window[b]?c.log(b+"already exists in global namespace"):window[b]=c[b]})};c.log=function(b,c){e&&(b+="
",e.innerHTML=c?e.innerHTML.toString()+ b:b)};c.init=function(f){d=document.getElementsByTagName("title")[0];c.url_parameters=c.getUrlParameters();e=document.getElementById("jaws-log");c.url_parameters.debug&&!e&&(e=document.createElement("div"),e.id="jaws-log",e.style.cssText="overflow: auto; color: #aaaaaa; width: 300px; height: 150px; margin: 40px auto 0px auto; padding: 5px; border: #444444 1px solid; clear: both; font: 10px verdana; text-align: left;",document.body.appendChild(e));c.canvas=document.getElementsByTagName("canvas")[0]; c.canvas||(c.dom=document.getElementById("canvas"));c.canvas?c.context=c.canvas.getContext("2d"):c.dom?c.dom.style.position="relative":(c.canvas=document.createElement("canvas"),c.canvas.width=f.width,c.canvas.height=f.height,c.context=c.canvas.getContext("2d"),document.body.appendChild(c.canvas));c.useCrispScaling();c.width=c.canvas?c.canvas.width:c.dom.offsetWidth;c.height=c.canvas?c.canvas.height:c.dom.offsetHeight;c.mouse_x=0;c.mouse_y=0;window.addEventListener("mousemove",b)};c.useCrispScaling= @@ -27,8 +27,8 @@ arguments.callee))return new arguments.callee(b,c,e,f);this.x=b;this.y=c;this.wi this.width;this.bottom=this.y+this.height;return this};c.Rect.prototype.resizeTo=function(b,c){this.width=b;this.height=c;this.right=this.x+this.width;this.bottom=this.y+this.height;return this};c.Rect.prototype.draw=function(){c.context.strokeStyle="red";c.context.strokeRect(this.x,this.y,this.width,this.height);return this};c.Rect.prototype.collidePoint=function(b,c){return b>=this.x&&b<=this.right&&c>=this.y&&c<=this.bottom};c.Rect.prototype.collideRect=function(b){return(this.x>=b.x&&this.x<= b.right||b.x>=this.x&&b.x<=this.right)&&(this.y>=b.y&&this.y<=b.bottom||b.y>=this.y&&b.y<=this.bottom)};c.Rect.prototype.toString=function(){return"[Rect "+this.x+", "+this.y+", "+this.width+", "+this.height+"]"};return c}(jaws||{});"undefined"!==typeof module&&"exports"in module&&(module.exports=jaws.Rect); jaws=function(c){c.Sprite=function(b){if(!(this instanceof arguments.callee))return new arguments.callee(b);this.set(b);b.context?this.context=b.context:b.dom&&(this.dom=b.dom,this.createDiv());!b.context&&!b.dom&&(c.context?this.context=c.context:(this.dom=c.dom,this.createDiv()))};c.Sprite.prototype.default_options={x:0,y:0,alpha:1,angle:0,flipped:!1,anchor_x:0,anchor_y:0,image:null,image_path:null,anchor:null,scale_image:null,damping:1,scale_x:1,scale_y:1,scale:1,width:null,height:null,_constructor:null, -dom:null};c.Sprite.prototype.set=function(b){c.parseOptions(this,b,this.default_options);this.scale&&(this.scale_x=this.scale_y=this.scale);this.image&&this.setImage(this.image);this.scale_image&&this.scaleImage(this.scale_image);this.anchor&&this.setAnchor(this.anchor);!this.image&&(this.color&&this.width&&this.height)&&(b=document.createElement("canvas").getContext("2d"),b.fillStyle=this.color,b.fillRect(0,0,this.width,this.height),this.image=b.getImageData(0,0,this.width,this.height));this.cacheOffsets(); -return this};c.Sprite.prototype.clone=function(){var b=new (this._constructor?eval(this._constructor):this.constructor)(this.attributes());b._constructor=this._constructor||this.constructor.name;return b};c.Sprite.prototype.setImage=function(b){var d=this;if(c.isDrawable(b))return this.image=b,this.cacheOffsets();c.assets.isLoaded(b)?(this.image=c.assets.get(b),this.cacheOffsets()):(console.log("WARNING: Image '"+b+"' not preloaded with jaws.assets.add(). Image and a working sprite.rect() will be delayed."), +dom:null,context:null};c.Sprite.prototype.set=function(b){c.parseOptions(this,b,this.default_options);this.scale&&(this.scale_x=this.scale_y=this.scale);this.image&&this.setImage(this.image);this.scale_image&&this.scaleImage(this.scale_image);this.anchor&&this.setAnchor(this.anchor);!this.image&&(this.color&&this.width&&this.height)&&(b=document.createElement("canvas").getContext("2d"),b.fillStyle=this.color,b.fillRect(0,0,this.width,this.height),this.image=b.getImageData(0,0,this.width,this.height)); +this.cacheOffsets();return this};c.Sprite.prototype.clone=function(){var b=new (this._constructor?eval(this._constructor):this.constructor)(this.attributes());b._constructor=this._constructor||this.constructor.name;return b};c.Sprite.prototype.setImage=function(b){var d=this;if(c.isDrawable(b))return this.image=b,this.cacheOffsets();c.assets.isLoaded(b)?(this.image=c.assets.get(b),this.cacheOffsets()):(console.log("WARNING: Image '"+b+"' not preloaded with jaws.assets.add(). Image and a working sprite.rect() will be delayed."), c.assets.load(b,function(){d.image=c.assets.get(b);d.cacheOffsets()}));return this};c.Sprite.prototype.flip=function(){this.flipped=this.flipped?!1:!0;return this};c.Sprite.prototype.flipTo=function(b){this.flipped=b;return this};c.Sprite.prototype.rotate=function(b){this.angle+=b;return this};c.Sprite.prototype.rotateTo=function(b){this.angle=b;return this};c.Sprite.prototype.moveTo=function(b,c){this.x=b;this.y=c;return this};c.Sprite.prototype.move=function(b,c){b&&(this.x+=b);c&&(this.y+=c);return this}; c.Sprite.prototype.scaleAll=function(b){this.scale_x*=b;this.scale_y*=b;return this.cacheOffsets()};c.Sprite.prototype.scaleTo=function(b){this.scale_x=this.scale_y=b;return this.cacheOffsets()};c.Sprite.prototype.scaleWidth=function(b){this.scale_x*=b;return this.cacheOffsets()};c.Sprite.prototype.scaleHeight=function(b){this.scale_y*=b;return this.cacheOffsets()};c.Sprite.prototype.setX=function(b){this.x=b;return this};c.Sprite.prototype.setY=function(b){this.y=b;return this};c.Sprite.prototype.setTop= function(b){this.y=b+this.top_offset;return this};c.Sprite.prototype.setBottom=function(b){this.y=b-this.bottom_offset;return this};c.Sprite.prototype.setLeft=function(b){this.x=b+this.left_offset;return this};c.Sprite.prototype.setRight=function(b){this.x=b-this.right_offset;return this};c.Sprite.prototype.setWidth=function(b){this.scale_x=b/this.image.width;return this.cacheOffsets()};c.Sprite.prototype.setHeight=function(b){this.scale_y=b/this.image.height;return this.cacheOffsets()};c.Sprite.prototype.resize= diff --git a/jaws.js b/jaws.js index 8a4333b..e99ff17 100644 --- a/jaws.js +++ b/jaws.js @@ -1,4 +1,4 @@ -/* Built at 2013-05-08 01:16:18 +0200 */ +/* Built at 2013-06-09 17:54:33 +0200 */ /** * @namespace JawsJS core functions. "Field Summary" contains readable properties on the main jaws-object. * @@ -1216,7 +1216,8 @@ jaws.Sprite.prototype.default_options = { width: null, height: null, _constructor: null, - dom: null + dom: null, + context: null } /**