Skip to content

Commit

Permalink
10.2.0 dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Nov 15, 2021
1 parent e024a2f commit 62d979f
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 12 deletions.
216 changes: 212 additions & 4 deletions dist/melonjs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* melonJS Game Engine - v10.1.1
* melonJS Game Engine - v10.2.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
Expand Down Expand Up @@ -31786,10 +31786,10 @@
* this can be overridden by the plugin
* @public
* @type String
* @default "10.1.1"
* @default "10.2.0"
* @name me.plugin.Base#version
*/
this.version = "10.1.1";
this.version = "10.2.0";
};

/**
Expand Down Expand Up @@ -34220,6 +34220,213 @@
return ImageLayer;
}(Sprite));

/**
* @classdesc
* A NineSliceSprite is similar to a Sprite, but it it can strech its inner area to fit the size of the Renderable
* @class NineSliceSprite
* @extends me.Sprite
* @memberOf me
* @constructor
* @param {Number} x the x coordinates of the sprite object
* @param {Number} y the y coordinates of the sprite object
* @param {Object} settings Configuration parameters for the Sprite object
* @param {Number} settings.width the width of the Renderable over which the sprite needs to be stretched
* @param {Number} settings.height the height of the Renderable over which the sprite needs to be stretched
* @param {me.Renderer.Texture|HTMLImageElement|HTMLCanvasElement|String} settings.image reference to a texture, spritesheet image or to a texture atlas
* @param {String} [settings.name=""] name of this object
* @param {String} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
* @param {Number} [settings.framewidth] Width of a single frame within the spritesheet
* @param {Number} [settings.frameheight] Height of a single frame within the spritesheet
* @param {String|Color} [settings.tint] a tint to be applied to this sprite
* @param {Number} [settings.flipX] flip the sprite on the horizontal axis
* @param {Number} [settings.flipY] flip the sprite on the vertical axis
* @param {me.Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
* @example
* this.panelSprite = new me.NineSliceSprite(0, 0, {
* image : game.texture,
* region : "grey_panel",
* width : this.width,
* height : this.height
* });
*/

var NineSliceSprite = /*@__PURE__*/(function (Sprite) {
function NineSliceSprite(x, y, settings) {
// call the super constructor
Sprite.call(this, x, y, settings);

// ensure mandatory properties are defined
if ((typeof settings.width !== "number") || (typeof settings.height !== "number")) {
throw new Error("height and width properties are mandatory");
}

// override the renderable sprite with the given one
// resize based on the active frame
this.width = settings.width;
this.height = settings.height;
}

if ( Sprite ) NineSliceSprite.__proto__ = Sprite;
NineSliceSprite.prototype = Object.create( Sprite && Sprite.prototype );
NineSliceSprite.prototype.constructor = NineSliceSprite;

/**
* @ignore
*/
NineSliceSprite.prototype.draw = function draw (renderer) {
// the frame to draw
var frame = this.current;

// cache the current position and size
var dx = this.pos.x,
dy = this.pos.y;

var w = frame.width,
h = frame.height;

// frame offset in the texture/atlas
var frame_offset = frame.offset;
var g_offset = this.offset;


// remove image's TexturePacker/ShoeBox rotation
if (frame.angle !== 0) {
renderer.translate(-dx, -dy);
renderer.rotate(frame.angle);
dx -= h;
w = frame.height;
h = frame.width;
}

var sx = g_offset.x + frame_offset.x,
sy = g_offset.y + frame_offset.y;

// should this be configurable ?
var corner_width = frame.width / 4,
corner_height = frame.height / 4;

// OPTIMIZE ME !

// DRAW CORNERS

// Top Left
renderer.drawImage(
this.image,
sx, // sx
sy, // sy
corner_width, corner_height, // sw,sh
dx, dy, // dx,dy
corner_width, corner_height // dw,dh
);

// Top Right
renderer.drawImage(
this.image,
sx + w - corner_width, // sx
sy, // sy
corner_width, corner_height, // sw,sh
dx + this.width - corner_width, // dx
dy, // dy
corner_width, corner_height // dw,dh
);
// Bottom Left
renderer.drawImage(
this.image,
sx, // sx
sy + h - corner_height, // sy
corner_width, corner_height, // sw,sh
dx, // dx
dy + this.height - corner_height, // dy
corner_width, corner_height // dw,dh
);
// Bottom Right
renderer.drawImage(
this.image,
sx + w - corner_width, // sx
sy + h - corner_height, // sy
corner_width, corner_height, // sw,sh
dx + this.width - corner_width, //dx
dy + this.height - corner_height, // dy
corner_width, corner_height // dw,dh
);


// DRAW SIDES and CENTER
var image_center_width = w - (corner_width << 1);
var image_center_height = h - (corner_height << 1);

var target_center_width = this.width - (corner_width << 1);
var target_center_height = this.height - (corner_height << 1);

//Top center
renderer.drawImage(
this.image,
sx + corner_width, // sx
sy, // sy
image_center_width, // sw
corner_height, // sh
dx + corner_width, // dx
dy, // dy
target_center_width, // dw
corner_height // dh
);

//Bottom center
renderer.drawImage(
this.image,
sx + corner_width, // sx
sy + h - corner_height, // sy
image_center_width, // sw
corner_height, // sh
dx + corner_width, // dx
dy + this.height - corner_height, // dx
target_center_width, // dw
corner_height // dh
);

// Middle Left
renderer.drawImage(
this.image,
sx, // sx
sy + corner_height, // sy
corner_width, // sw
image_center_height, // sh
dx, // dx
dy + corner_height, // dy
corner_width, // dw
target_center_height // dh
);

// Middle Right
renderer.drawImage(
this.image,
sx + w - corner_width, // sx
sy + corner_height, // sy
corner_width, // sw
image_center_height, // sh
dx + this.width - corner_width, // dx
dy + corner_height, // dy
corner_width, // dw
target_center_height // dh
);

// Middle Center
renderer.drawImage(
this.image,
sx + corner_width, // sx
sy + corner_height, // sy
image_center_width, // sw
image_center_height, // sh
dx + corner_width, // dx
dy + corner_height, // dy
target_center_width, // dw
target_center_height // dh
);
};

return NineSliceSprite;
}(Sprite));

/**
* @classdesc
* GUI Object<br>
Expand Down Expand Up @@ -36058,7 +36265,7 @@
* @name version
* @type {string}
*/
var version = "10.1.1";
var version = "10.2.0";


/**
Expand Down Expand Up @@ -36187,6 +36394,7 @@
exports.Math = math;
exports.Matrix2d = Matrix2d;
exports.Matrix3d = Matrix3d;
exports.NineSliceSprite = NineSliceSprite;
exports.ObservableVector2d = ObservableVector2d;
exports.ObservableVector3d = ObservableVector3d;
exports.Particle = Particle;
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.min.js

Large diffs are not rendered by default.

43 changes: 42 additions & 1 deletion dist/melonjs.module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3643,6 +3643,47 @@ export class Matrix3d {
*/
toString(): string;
}
/**
* @classdesc
* A NineSliceSprite is similar to a Sprite, but it it can strech its inner area to fit the size of the Renderable
* @class NineSliceSprite
* @extends me.Sprite
* @memberOf me
* @constructor
* @param {Number} x the x coordinates of the sprite object
* @param {Number} y the y coordinates of the sprite object
* @param {Object} settings Configuration parameters for the Sprite object
* @param {Number} settings.width the width of the Renderable over which the sprite needs to be stretched
* @param {Number} settings.height the height of the Renderable over which the sprite needs to be stretched
* @param {me.Renderer.Texture|HTMLImageElement|HTMLCanvasElement|String} settings.image reference to a texture, spritesheet image or to a texture atlas
* @param {String} [settings.name=""] name of this object
* @param {String} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
* @param {Number} [settings.framewidth] Width of a single frame within the spritesheet
* @param {Number} [settings.frameheight] Height of a single frame within the spritesheet
* @param {String|Color} [settings.tint] a tint to be applied to this sprite
* @param {Number} [settings.flipX] flip the sprite on the horizontal axis
* @param {Number} [settings.flipY] flip the sprite on the vertical axis
* @param {me.Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
* @example
* this.panelSprite = new me.NineSliceSprite(0, 0, {
* image : game.texture,
* region : "grey_panel",
* width : this.width,
* height : this.height
* });
*/
export class NineSliceSprite {
/**
* @ignore
*/
constructor(x: any, y: any, settings: any);
width: any;
height: any;
/**
* @ignore
*/
draw(renderer: any): void;
}
/**
* @classdesc
* A Vector2d object that provide notification by executing the given callback when the vector is changed.
Expand Down Expand Up @@ -12926,7 +12967,7 @@ declare class BasePlugin {
* this can be overridden by the plugin
* @public
* @type String
* @default "10.1.1"
* @default "10.2.0"
* @name me.plugin.Base#version
*/
public version: string;
Expand Down
Loading

0 comments on commit 62d979f

Please sign in to comment.