melonjs 9.0.2 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/melonjs.js +40 -43
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.js +40 -43
- package/package.json +3 -3
- package/src/level/tiled/TMXTileMap.js +4 -0
- package/src/renderable/imagelayer.js +17 -38
- package/src/renderable/renderable.js +2 -1
- package/src/renderable/sprite.js +14 -0
- package/src/utils/string.js +2 -2
package/README.md
CHANGED
|
@@ -45,9 +45,9 @@ and currently features :
|
|
|
45
45
|
- Uncompressed Plain, Base64, CSV and JSON encoded XML tilemap loading
|
|
46
46
|
- Orthogonal, Isometric and Hexagonal maps (both normal and staggered)
|
|
47
47
|
- Multiple layers (multiple background/foreground, collision and Image layers)
|
|
48
|
-
-
|
|
49
|
-
- Tileset
|
|
50
|
-
- Layers
|
|
48
|
+
- Animated and multiple Tileset support
|
|
49
|
+
- Tileset transparency settings
|
|
50
|
+
- Layers alpha and tinting settings
|
|
51
51
|
- Rectangle, Ellipse, Polygon and Polyline objects support
|
|
52
52
|
- Tiled Objects
|
|
53
53
|
- Flipped & rotated Tiles
|
package/dist/melonjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v9.0
|
|
2
|
+
* melonJS Game Engine - v9.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
return str.replace(/\s+$/, "");
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* returns true if the given string contains a numeric
|
|
75
|
+
* returns true if the given string contains a numeric integer or float value
|
|
76
76
|
* @public
|
|
77
77
|
* @function
|
|
78
78
|
* @memberOf me.utils.string
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
if (typeof str === "string") {
|
|
85
85
|
str = str.trim();
|
|
86
86
|
}
|
|
87
|
-
return !isNaN(str) &&
|
|
87
|
+
return !isNaN(str) && /[+-]?([0-9]*[.])?[0-9]+/.test(str);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* returns true if the given string contains a true or false
|
|
@@ -13533,7 +13533,8 @@
|
|
|
13533
13533
|
* <img src="images/anchor_point.png"/><br>
|
|
13534
13534
|
* a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
|
|
13535
13535
|
* <br>
|
|
13536
|
-
* <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation
|
|
13536
|
+
* <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
|
|
13537
|
+
* To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
|
|
13537
13538
|
* @public
|
|
13538
13539
|
* @type me.ObservableVector2d
|
|
13539
13540
|
* @default <0.5,0.5>
|
|
@@ -21160,6 +21161,15 @@
|
|
|
21160
21161
|
this.textureAtlas = this.source.getAtlas();
|
|
21161
21162
|
}
|
|
21162
21163
|
|
|
21164
|
+
// throw an error if image ends up being null/undefined
|
|
21165
|
+
if (!this.image) {
|
|
21166
|
+
throw new Error((
|
|
21167
|
+
(typeof(settings.image) === "string") ?
|
|
21168
|
+
"'" + settings.image + "'" :
|
|
21169
|
+
"Image"
|
|
21170
|
+
) + " file for Image Layer '" + this.name + "' not found!");
|
|
21171
|
+
}
|
|
21172
|
+
|
|
21163
21173
|
// store/reset the current atlas information if specified
|
|
21164
21174
|
if (typeof(settings.atlas) !== "undefined") {
|
|
21165
21175
|
this.textureAtlas = settings.atlas;
|
|
@@ -21198,6 +21208,10 @@
|
|
|
21198
21208
|
this.name = settings.name;
|
|
21199
21209
|
}
|
|
21200
21210
|
|
|
21211
|
+
// displaying order
|
|
21212
|
+
if (typeof settings.z !== "undefined") {
|
|
21213
|
+
this.pos.z = settings.z;
|
|
21214
|
+
}
|
|
21201
21215
|
// for sprite, addAnimation will return !=0
|
|
21202
21216
|
if (this.addAnimation("default", null) !== 0) {
|
|
21203
21217
|
// set as default
|
|
@@ -25943,10 +25957,14 @@
|
|
|
25943
25957
|
Object.assign({
|
|
25944
25958
|
name: data.name,
|
|
25945
25959
|
image: data.image,
|
|
25960
|
+
ratio : pool.pull("Vector2d", +data.parallaxx || 1.0, +data.parallaxy || 1.0),
|
|
25961
|
+
// convert to melonJS color format (note: this should be done earlier when parsing data)
|
|
25962
|
+
tint : typeof (data.tintcolor) !== "undefined" ? (pool.pull("Color")).parseHex(data.tintcolor, true) : undefined,
|
|
25946
25963
|
z: z
|
|
25947
25964
|
}, data.properties)
|
|
25948
25965
|
);
|
|
25949
25966
|
|
|
25967
|
+
|
|
25950
25968
|
// set some additional flags
|
|
25951
25969
|
var visible = typeof(data.visible) !== "undefined" ? data.visible : true;
|
|
25952
25970
|
imageLayer.setOpacity(visible ? +data.opacity : 0);
|
|
@@ -32506,10 +32524,10 @@
|
|
|
32506
32524
|
* this can be overridden by the plugin
|
|
32507
32525
|
* @public
|
|
32508
32526
|
* @type String
|
|
32509
|
-
* @default "9.0
|
|
32527
|
+
* @default "9.1.0"
|
|
32510
32528
|
* @name me.plugin.Base#version
|
|
32511
32529
|
*/
|
|
32512
|
-
this.version = "9.0
|
|
32530
|
+
this.version = "9.1.0";
|
|
32513
32531
|
}
|
|
32514
32532
|
}),
|
|
32515
32533
|
|
|
@@ -34706,41 +34724,19 @@
|
|
|
34706
34724
|
* repeat :"repeat-x"
|
|
34707
34725
|
* }), 1);
|
|
34708
34726
|
*/
|
|
34709
|
-
var ImageLayer =
|
|
34727
|
+
var ImageLayer = Sprite.extend({
|
|
34710
34728
|
/**
|
|
34711
34729
|
* @ignore
|
|
34712
34730
|
*/
|
|
34713
34731
|
init: function (x, y, settings) {
|
|
34714
34732
|
// call the constructor
|
|
34715
|
-
this._super(
|
|
34716
|
-
|
|
34717
|
-
// get the corresponding image
|
|
34718
|
-
this.image = (typeof settings.image === "object") ? settings.image : loader$1.getImage(settings.image);
|
|
34719
|
-
|
|
34720
|
-
// throw an error if image is null/undefined
|
|
34721
|
-
if (!this.image) {
|
|
34722
|
-
throw new Error((
|
|
34723
|
-
(typeof(settings.image) === "string") ?
|
|
34724
|
-
"'" + settings.image + "'" :
|
|
34725
|
-
"Image"
|
|
34726
|
-
) + " file for Image Layer '" + this.name + "' not found!");
|
|
34727
|
-
}
|
|
34728
|
-
|
|
34729
|
-
this.imagewidth = this.image.width;
|
|
34730
|
-
this.imageheight = this.image.height;
|
|
34731
|
-
|
|
34732
|
-
// set the sprite name if specified
|
|
34733
|
-
if (typeof (settings.name) === "string") {
|
|
34734
|
-
this.name = settings.name;
|
|
34735
|
-
}
|
|
34733
|
+
this._super(Sprite, "init", [x, y, settings]);
|
|
34736
34734
|
|
|
34737
34735
|
// render in screen coordinates
|
|
34738
34736
|
this.floating = true;
|
|
34739
34737
|
|
|
34740
|
-
//
|
|
34741
|
-
this.
|
|
34742
|
-
|
|
34743
|
-
this.offset = pool.pull("Vector2d", x, y);
|
|
34738
|
+
// image drawing offset
|
|
34739
|
+
this.offset.set(x, y);
|
|
34744
34740
|
|
|
34745
34741
|
/**
|
|
34746
34742
|
* Define the image scrolling ratio<br>
|
|
@@ -34758,8 +34754,8 @@
|
|
|
34758
34754
|
|
|
34759
34755
|
if (typeof(settings.ratio) !== "undefined") {
|
|
34760
34756
|
// little hack for backward compatiblity
|
|
34761
|
-
if (
|
|
34762
|
-
this.ratio.set(settings.ratio, settings.ratio);
|
|
34757
|
+
if (utils$1.string.isNumeric(settings.ratio)) {
|
|
34758
|
+
this.ratio.set(settings.ratio, +settings.ratio);
|
|
34763
34759
|
} else /* vector */ {
|
|
34764
34760
|
this.ratio.setV(settings.ratio);
|
|
34765
34761
|
}
|
|
@@ -34875,7 +34871,7 @@
|
|
|
34875
34871
|
* @param {Number} h new height
|
|
34876
34872
|
*/
|
|
34877
34873
|
resize : function (w, h) {
|
|
34878
|
-
this._super(
|
|
34874
|
+
this._super(Sprite, "resize", [
|
|
34879
34875
|
this.repeatX ? Infinity : w,
|
|
34880
34876
|
this.repeatY ? Infinity : h
|
|
34881
34877
|
]);
|
|
@@ -34905,8 +34901,8 @@
|
|
|
34905
34901
|
}
|
|
34906
34902
|
|
|
34907
34903
|
var viewport = game$1.viewport,
|
|
34908
|
-
width = this.
|
|
34909
|
-
height = this.
|
|
34904
|
+
width = this.width,
|
|
34905
|
+
height = this.height,
|
|
34910
34906
|
bw = viewport.bounds.width,
|
|
34911
34907
|
bh = viewport.bounds.height,
|
|
34912
34908
|
ax = this.anchorPoint.x,
|
|
@@ -34949,6 +34945,9 @@
|
|
|
34949
34945
|
renderer.save();
|
|
34950
34946
|
// apply the defined alpha value
|
|
34951
34947
|
renderer.setGlobalAlpha(renderer.globalAlpha() * this.getOpacity());
|
|
34948
|
+
|
|
34949
|
+
// apply the defined tint, if any
|
|
34950
|
+
renderer.setTint(this.tint);
|
|
34952
34951
|
},
|
|
34953
34952
|
|
|
34954
34953
|
/**
|
|
@@ -34957,8 +34956,8 @@
|
|
|
34957
34956
|
*/
|
|
34958
34957
|
draw : function (renderer) {
|
|
34959
34958
|
var viewport = game$1.viewport,
|
|
34960
|
-
width = this.
|
|
34961
|
-
height = this.
|
|
34959
|
+
width = this.width,
|
|
34960
|
+
height = this.height,
|
|
34962
34961
|
bw = viewport.bounds.width,
|
|
34963
34962
|
bh = viewport.bounds.height,
|
|
34964
34963
|
ax = this.anchorPoint.x,
|
|
@@ -34995,11 +34994,9 @@
|
|
|
34995
34994
|
* @ignore
|
|
34996
34995
|
*/
|
|
34997
34996
|
destroy : function () {
|
|
34998
|
-
pool.push(this.offset);
|
|
34999
|
-
this.offset = undefined;
|
|
35000
34997
|
pool.push(this.ratio);
|
|
35001
34998
|
this.ratio = undefined;
|
|
35002
|
-
this._super(
|
|
34999
|
+
this._super(Sprite, "destroy");
|
|
35003
35000
|
}
|
|
35004
35001
|
});
|
|
35005
35002
|
|
|
@@ -36781,7 +36778,7 @@
|
|
|
36781
36778
|
* @name version
|
|
36782
36779
|
* @type {string}
|
|
36783
36780
|
*/
|
|
36784
|
-
var version = "9.0
|
|
36781
|
+
var version = "9.1.0";
|
|
36785
36782
|
|
|
36786
36783
|
|
|
36787
36784
|
/**
|