dist/melonjs.js
function setRegion(region) {
         if (this.source !== null) {
           // set the source texture for the given region
           this.image = this.source.getTexture(region);
         } // set the sprite offset within the texture


         this.current.offset.setV(region.offset); // set angle if defined

         this.current.angle = region.angle; // update the default "current" size

         this.width = this.current.width = region.width;
         this.height = this.current.height = region.height; // set global anchortPoint if defined

         if (region.anchorPoint) {
           this.anchorPoint.set(this._flip.x && region.trimmed === true ? 1 - region.anchorPoint.x : region.anchorPoint.x, this._flip.y && region.trimmed === true ? 1 - region.anchorPoint.y : region.anchorPoint.y);
         }

         return this;
       }
function setRegion(region) {
         if (this.source !== null) {
           // set the source texture for the given region
           this.image = this.source.getTexture(region);
         } // set the sprite offset within the texture


         this.current.offset.setV(region.offset); // set angle if defined

         this.current.angle = region.angle; // update the default "current" size

         this.width = this.current.width = region.width;
         this.height = this.current.height = region.height; // set global anchortPoint if defined

         if (region.anchorPoint) {
           this.anchorPoint.set(this._flip.x && region.trimmed === true ? 1 - region.anchorPoint.x : region.anchorPoint.x, this._flip.y && region.trimmed === true ? 1 - region.anchorPoint.y : region.anchorPoint.y);
         }

         return this;
       }
function setRegion ( region ) { if ( this . source !== null ) { // set the source texture for the given region this . image = this . source . getTexture ( region ) ; } // set the sprite offset within the texture this . current . offset . setV ( region . offset ) ; // set angle if defined this . current . angle = region . angle ; // update the default "current" size this . width = this . current . width = region . width ; this . height = this . current . height = region . height ; // set global anchortPoint if defined if ( region . anchorPoint ) { this . anchorPoint . set ( this . _flip . x && region . trimmed === true ? 1 - region . anchorPoint . x : region . anchorPoint . x , this . _flip . y && region . trimmed === true ? 1 - region . anchorPoint . y : region . anchorPoint . y ) ; } return this ; }
change the current texture atlas region for this sprite
@see me.Texture.getRegion
@name setRegion
@memberOf me.Sprite.prototype
@function
@param {Object} region typically returned through me.Texture.getRegion()
@return {me.Sprite} Reference to this object for method chaining
@example
// change the sprite to "shadedDark13.png";
mySprite.setRegion(game.texture.getRegion("shadedDark13.png"));
change the current texture atlas region for this sprite