melonjs 10.2.1 → 10.2.2
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 +1 -1
- package/dist/melonjs.js +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
package/src/text/bitmaptext.js
CHANGED
|
@@ -38,18 +38,19 @@ var measureTextHeight = function(font) {
|
|
|
38
38
|
* @extends me.Renderable
|
|
39
39
|
* @memberOf me
|
|
40
40
|
* @constructor
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {
|
|
41
|
+
* @param {number} x position of the text object
|
|
42
|
+
* @param {number} y position of the text object
|
|
43
|
+
* @param {object} settings the text configuration
|
|
44
|
+
* @param {string|Image} settings.font a font name to identify the corresponing source image
|
|
45
|
+
* @param {string} [settings.fontData=settings.font] the bitmap font data corresponding name, or the bitmap font data itself
|
|
46
|
+
* @param {number} [settings.size] size a scaling ratio
|
|
47
|
+
* @param {me.Color|string} [settings.fillStyle] a CSS color value used to tint the bitmapText (@see me.BitmapText.tint)
|
|
48
|
+
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
49
|
+
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
50
|
+
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
51
|
+
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
51
52
|
* @param {me.Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
52
|
-
* @param {(
|
|
53
|
+
* @param {(string|string[])} [settings.text] a string, or an array of strings
|
|
53
54
|
* @example
|
|
54
55
|
* // Use me.loader.preload or me.loader.load to load assets
|
|
55
56
|
* me.loader.preload([
|
|
@@ -76,7 +77,7 @@ class BitmapText extends Renderable {
|
|
|
76
77
|
* Set the default text alignment (or justification),<br>
|
|
77
78
|
* possible values are "left", "right", and "center".
|
|
78
79
|
* @public
|
|
79
|
-
* @type
|
|
80
|
+
* @type {string}
|
|
80
81
|
* @default "left"
|
|
81
82
|
* @name textAlign
|
|
82
83
|
* @memberOf me.BitmapText
|
|
@@ -87,7 +88,7 @@ class BitmapText extends Renderable {
|
|
|
87
88
|
* Set the text baseline (e.g. the Y-coordinate for the draw operation), <br>
|
|
88
89
|
* possible values are "top", "hanging, "middle, "alphabetic, "ideographic, "bottom"<br>
|
|
89
90
|
* @public
|
|
90
|
-
* @type
|
|
91
|
+
* @type {string}
|
|
91
92
|
* @default "top"
|
|
92
93
|
* @name textBaseline
|
|
93
94
|
* @memberOf me.BitmapText
|
|
@@ -98,7 +99,7 @@ class BitmapText extends Renderable {
|
|
|
98
99
|
* Set the line spacing height (when displaying multi-line strings). <br>
|
|
99
100
|
* Current font height will be multiplied with this value to set the line height.
|
|
100
101
|
* @public
|
|
101
|
-
* @type
|
|
102
|
+
* @type {number}
|
|
102
103
|
* @default 1.0
|
|
103
104
|
* @name lineHeight
|
|
104
105
|
* @memberOf me.BitmapText
|
|
@@ -108,7 +109,7 @@ class BitmapText extends Renderable {
|
|
|
108
109
|
/**
|
|
109
110
|
* the text to be displayed
|
|
110
111
|
* @private
|
|
111
|
-
* @type {
|
|
112
|
+
* @type {string[]}
|
|
112
113
|
* @name _text
|
|
113
114
|
* @memberOf me.BitmapText
|
|
114
115
|
*/
|
|
@@ -167,9 +168,9 @@ class BitmapText extends Renderable {
|
|
|
167
168
|
* @name set
|
|
168
169
|
* @memberOf me.BitmapText.prototype
|
|
169
170
|
* @function
|
|
170
|
-
* @param {
|
|
171
|
-
* @param {
|
|
172
|
-
* @
|
|
171
|
+
* @param {string} textAlign ("left", "center", "right")
|
|
172
|
+
* @param {number} [scale]
|
|
173
|
+
* @returns {me.BitmapText} this object for chaining
|
|
173
174
|
*/
|
|
174
175
|
set(textAlign, scale) {
|
|
175
176
|
this.textAlign = textAlign;
|
|
@@ -187,8 +188,8 @@ class BitmapText extends Renderable {
|
|
|
187
188
|
* @name setText
|
|
188
189
|
* @memberOf me.BitmapText.prototype
|
|
189
190
|
* @function
|
|
190
|
-
* @param {
|
|
191
|
-
* @
|
|
191
|
+
* @param {number|string|string[]} value a string, or an array of strings
|
|
192
|
+
* @returns {me.BitmapText} this object for chaining
|
|
192
193
|
*/
|
|
193
194
|
setText(value) {
|
|
194
195
|
if (typeof value === "undefined") {
|
|
@@ -215,16 +216,9 @@ class BitmapText extends Renderable {
|
|
|
215
216
|
* @see me.Renderable#tint
|
|
216
217
|
* @memberOf me.BitmapText
|
|
217
218
|
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @ignore
|
|
221
|
-
*/
|
|
222
219
|
get fillStyle() {
|
|
223
220
|
return this.tint;
|
|
224
221
|
}
|
|
225
|
-
/**
|
|
226
|
-
* @ignore
|
|
227
|
-
*/
|
|
228
222
|
set fillStyle(value) {
|
|
229
223
|
this.tint = value;
|
|
230
224
|
}
|
|
@@ -234,8 +228,8 @@ class BitmapText extends Renderable {
|
|
|
234
228
|
* @name resize
|
|
235
229
|
* @memberOf me.BitmapText.prototype
|
|
236
230
|
* @function
|
|
237
|
-
* @param {
|
|
238
|
-
* @
|
|
231
|
+
* @param {number} scale ratio
|
|
232
|
+
* @returns {me.BitmapText} this object for chaining
|
|
239
233
|
*/
|
|
240
234
|
resize(scale) {
|
|
241
235
|
this.fontScale.set(scale, scale);
|
|
@@ -250,7 +244,7 @@ class BitmapText extends Renderable {
|
|
|
250
244
|
* @name measureText
|
|
251
245
|
* @memberOf me.BitmapText.prototype
|
|
252
246
|
* @function
|
|
253
|
-
* @param {
|
|
247
|
+
* @param {string} [text]
|
|
254
248
|
* @param {me.Rect} [ret] a object in which to store the text metrics
|
|
255
249
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
256
250
|
*/
|
|
@@ -286,9 +280,9 @@ class BitmapText extends Renderable {
|
|
|
286
280
|
* @memberOf me.BitmapText.prototype
|
|
287
281
|
* @function
|
|
288
282
|
* @param {me.CanvasRenderer|me.WebGLRenderer} renderer Reference to the destination renderer instance
|
|
289
|
-
* @param {
|
|
290
|
-
* @param {
|
|
291
|
-
* @param {
|
|
283
|
+
* @param {string} [text]
|
|
284
|
+
* @param {number} [x]
|
|
285
|
+
* @param {number} [y]
|
|
292
286
|
*/
|
|
293
287
|
draw(renderer, text, x, y) {
|
|
294
288
|
// save the previous global alpha value
|
|
@@ -5,7 +5,7 @@ var capChars = ["M", "N", "B", "D", "C", "E", "F", "K", "A", "G", "H", "I", "J",
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Gets the value from a string of pairs.
|
|
8
|
-
* @
|
|
8
|
+
* @ignore
|
|
9
9
|
*/
|
|
10
10
|
function getValueFromPair(string, pattern) {
|
|
11
11
|
var value = string.match(pattern);
|
|
@@ -18,11 +18,11 @@ function getValueFromPair(string, pattern) {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Gets the first glyph in the map that is not a space character
|
|
21
|
-
* @
|
|
21
|
+
* @ignore
|
|
22
22
|
* @name _getFirstGlyph
|
|
23
23
|
* @memberOf me.BitmapTextData
|
|
24
24
|
* @function
|
|
25
|
-
* @param {
|
|
25
|
+
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
26
26
|
* @returns {me.Glyph}
|
|
27
27
|
*/
|
|
28
28
|
function getFirstGlyph(glyphs) {
|
|
@@ -37,11 +37,11 @@ function getFirstGlyph(glyphs) {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Creates a glyph to use for the space character
|
|
40
|
-
* @
|
|
40
|
+
* @ignore
|
|
41
41
|
* @name createSpaceGlyph
|
|
42
42
|
* @memberOf me.BitmapTextData
|
|
43
43
|
* @function
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
45
45
|
*/
|
|
46
46
|
function createSpaceGlyph(glyphs) {
|
|
47
47
|
var spaceCharCode = " ".charCodeAt(0);
|
|
@@ -60,8 +60,8 @@ function createSpaceGlyph(glyphs) {
|
|
|
60
60
|
* Class for storing relevant data from the font file.
|
|
61
61
|
* @class me.BitmapTextData
|
|
62
62
|
* @memberOf me
|
|
63
|
-
* @
|
|
64
|
-
* @param data {
|
|
63
|
+
* @ignore
|
|
64
|
+
* @param data {string} - The bitmap font data pulled from the resource loader using me.loader.getBinary()
|
|
65
65
|
* @constructor
|
|
66
66
|
*/
|
|
67
67
|
class BitmapTextData {
|
|
@@ -88,7 +88,7 @@ class BitmapTextData {
|
|
|
88
88
|
/**
|
|
89
89
|
* The map of glyphs, each key is a char code.
|
|
90
90
|
* @name glyphs
|
|
91
|
-
* @type {
|
|
91
|
+
* @type {object}
|
|
92
92
|
* @memberOf me.BitmapTextData
|
|
93
93
|
*/
|
|
94
94
|
this.glyphs = {};
|
|
@@ -102,7 +102,7 @@ class BitmapTextData {
|
|
|
102
102
|
* @name parse
|
|
103
103
|
* @memberOf me.BitmapTextData
|
|
104
104
|
* @function
|
|
105
|
-
* @param {
|
|
105
|
+
* @param {string} fontData
|
|
106
106
|
*/
|
|
107
107
|
parse(fontData) {
|
|
108
108
|
if (!fontData) {
|
package/src/text/text.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Color from "./../math/color.js";
|
|
2
|
-
import Renderer from "./../video/renderer.js";
|
|
3
2
|
import WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
4
3
|
import { renderer, createCanvas } from "./../video/video.js";
|
|
5
4
|
import * as stringUtil from "./../utils/string.js";
|
|
@@ -42,20 +41,20 @@ var setContextStyle = function(context, font, stroke = false) {
|
|
|
42
41
|
* @extends me.Renderable
|
|
43
42
|
* @memberOf me
|
|
44
43
|
* @constructor
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {me.Color|
|
|
51
|
-
* @param {me.Color|
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
44
|
+
* @param {number} x position of the text object
|
|
45
|
+
* @param {number} y position of the text object
|
|
46
|
+
* @param {object} settings the text configuration
|
|
47
|
+
* @param {string} settings.font a CSS family font name
|
|
48
|
+
* @param {number|string} settings.size size, or size + suffix (px, em, pt)
|
|
49
|
+
* @param {me.Color|string} [settings.fillStyle="#000000"] a CSS color value
|
|
50
|
+
* @param {me.Color|string} [settings.strokeStyle="#000000"] a CSS color value
|
|
51
|
+
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
52
|
+
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
53
|
+
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
54
|
+
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
56
55
|
* @param {me.Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {(
|
|
56
|
+
* @param {boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
57
|
+
* @param {(string|string[])} [settings.text=""] a string, or an array of strings
|
|
59
58
|
* @example
|
|
60
59
|
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
61
60
|
*/
|
|
@@ -74,7 +73,7 @@ class Text extends Renderable {
|
|
|
74
73
|
/**
|
|
75
74
|
* defines the color used to draw the font.<br>
|
|
76
75
|
* @public
|
|
77
|
-
* @type me.Color
|
|
76
|
+
* @type {me.Color}
|
|
78
77
|
* @default black
|
|
79
78
|
* @name me.Text#fillStyle
|
|
80
79
|
*/
|
|
@@ -92,7 +91,7 @@ class Text extends Renderable {
|
|
|
92
91
|
/**
|
|
93
92
|
* defines the color used to draw the font stroke.<br>
|
|
94
93
|
* @public
|
|
95
|
-
* @type me.Color
|
|
94
|
+
* @type {me.Color}
|
|
96
95
|
* @default black
|
|
97
96
|
* @name me.Text#strokeStyle
|
|
98
97
|
*/
|
|
@@ -110,7 +109,7 @@ class Text extends Renderable {
|
|
|
110
109
|
/**
|
|
111
110
|
* sets the current line width, in pixels, when drawing stroke
|
|
112
111
|
* @public
|
|
113
|
-
* @type
|
|
112
|
+
* @type {number}
|
|
114
113
|
* @default 1
|
|
115
114
|
* @name me.Text#lineWidth
|
|
116
115
|
*/
|
|
@@ -120,7 +119,7 @@ class Text extends Renderable {
|
|
|
120
119
|
* Set the default text alignment (or justification),<br>
|
|
121
120
|
* possible values are "left", "right", and "center".<br>
|
|
122
121
|
* @public
|
|
123
|
-
* @type
|
|
122
|
+
* @type {string}
|
|
124
123
|
* @default "left"
|
|
125
124
|
* @name me.Text#textAlign
|
|
126
125
|
*/
|
|
@@ -130,7 +129,7 @@ class Text extends Renderable {
|
|
|
130
129
|
* Set the text baseline (e.g. the Y-coordinate for the draw operation), <br>
|
|
131
130
|
* possible values are "top", "hanging, "middle, "alphabetic, "ideographic, "bottom"<br>
|
|
132
131
|
* @public
|
|
133
|
-
* @type
|
|
132
|
+
* @type {string}
|
|
134
133
|
* @default "top"
|
|
135
134
|
* @name me.Text#textBaseline
|
|
136
135
|
*/
|
|
@@ -140,7 +139,7 @@ class Text extends Renderable {
|
|
|
140
139
|
* Set the line spacing height (when displaying multi-line strings). <br>
|
|
141
140
|
* Current font height will be multiplied with this value to set the line height.
|
|
142
141
|
* @public
|
|
143
|
-
* @type
|
|
142
|
+
* @type {number}
|
|
144
143
|
* @default 1.0
|
|
145
144
|
* @name me.Text#lineHeight
|
|
146
145
|
*/
|
|
@@ -151,7 +150,7 @@ class Text extends Renderable {
|
|
|
151
150
|
* Note: this will improve performances when using WebGL, but will impact
|
|
152
151
|
* memory consumption as every text element will have its own canvas texture
|
|
153
152
|
* @public
|
|
154
|
-
* @type
|
|
153
|
+
* @type {boolean}
|
|
155
154
|
* @default false
|
|
156
155
|
* @name me.Text#offScreenCanvas
|
|
157
156
|
*/
|
|
@@ -160,7 +159,7 @@ class Text extends Renderable {
|
|
|
160
159
|
/**
|
|
161
160
|
* the text to be displayed
|
|
162
161
|
* @private
|
|
163
|
-
* @type {
|
|
162
|
+
* @type {string[]}
|
|
164
163
|
* @name _text
|
|
165
164
|
* @memberOf me.Text
|
|
166
165
|
*/
|
|
@@ -169,11 +168,11 @@ class Text extends Renderable {
|
|
|
169
168
|
/**
|
|
170
169
|
* the font size (in px)
|
|
171
170
|
* @public
|
|
172
|
-
* @type {
|
|
171
|
+
* @type {number}
|
|
173
172
|
* @name fontSize
|
|
174
173
|
* @default 10
|
|
175
174
|
* @memberOf me.Text
|
|
176
|
-
|
|
175
|
+
*/
|
|
177
176
|
this.fontSize = 10;
|
|
178
177
|
|
|
179
178
|
// anchor point
|
|
@@ -231,7 +230,7 @@ class Text extends Renderable {
|
|
|
231
230
|
* @name bold
|
|
232
231
|
* @memberOf me.Text.prototype
|
|
233
232
|
* @function
|
|
234
|
-
* @
|
|
233
|
+
* @returns {me.Text} this object for chaining
|
|
235
234
|
*/
|
|
236
235
|
bold() {
|
|
237
236
|
this.font = "bold " + this.font;
|
|
@@ -244,7 +243,7 @@ class Text extends Renderable {
|
|
|
244
243
|
* @name italic
|
|
245
244
|
* @memberOf me.Text.prototype
|
|
246
245
|
* @function
|
|
247
|
-
* @
|
|
246
|
+
* @returns {me.Text} this object for chaining
|
|
248
247
|
*/
|
|
249
248
|
italic() {
|
|
250
249
|
this.font = "italic " + this.font;
|
|
@@ -257,9 +256,9 @@ class Text extends Renderable {
|
|
|
257
256
|
* @name setFont
|
|
258
257
|
* @memberOf me.Text.prototype
|
|
259
258
|
* @function
|
|
260
|
-
* @param {
|
|
261
|
-
* @param {
|
|
262
|
-
* @
|
|
259
|
+
* @param {string} font a CSS font name
|
|
260
|
+
* @param {number|string} [size=10] size in px, or size + suffix (px, em, pt)
|
|
261
|
+
* @returns {me.Text} this object for chaining
|
|
263
262
|
* @example
|
|
264
263
|
* font.setFont("Arial", 20);
|
|
265
264
|
* font.setFont("Arial", "1.5em");
|
|
@@ -301,8 +300,8 @@ class Text extends Renderable {
|
|
|
301
300
|
* @name setText
|
|
302
301
|
* @memberOf me.Text.prototype
|
|
303
302
|
* @function
|
|
304
|
-
* @param {
|
|
305
|
-
* @
|
|
303
|
+
* @param {number|string|string[]} value a string, or an array of strings
|
|
304
|
+
* @returns {me.Text} this object for chaining
|
|
306
305
|
*/
|
|
307
306
|
setText(value = "") {
|
|
308
307
|
if (this._text.toString() !== value.toString()) {
|
|
@@ -323,11 +322,11 @@ class Text extends Renderable {
|
|
|
323
322
|
* @memberOf me.Text.prototype
|
|
324
323
|
* @function
|
|
325
324
|
* @param {me.CanvasRenderer|me.WebGLRenderer} [renderer] reference to the active renderer
|
|
326
|
-
* @param {
|
|
325
|
+
* @param {string} [text] the text to be measured
|
|
327
326
|
* @param {me.Rect|me.Bounds} [ret] a object in which to store the text metrics
|
|
328
327
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
329
328
|
*/
|
|
330
|
-
measureText(
|
|
329
|
+
measureText(renderer, text, ret) {
|
|
331
330
|
var context;
|
|
332
331
|
var textMetrics = ret || this.getBounds();
|
|
333
332
|
var lineHeight = this.fontSize * this.lineHeight;
|
|
@@ -335,8 +334,6 @@ class Text extends Renderable {
|
|
|
335
334
|
|
|
336
335
|
if (this.offScreenCanvas === true) {
|
|
337
336
|
context = this.context;
|
|
338
|
-
} else if (_renderer instanceof Renderer) {
|
|
339
|
-
context = _renderer.getFontContext();
|
|
340
337
|
} else {
|
|
341
338
|
context = renderer.getFontContext();
|
|
342
339
|
}
|
|
@@ -413,9 +410,10 @@ class Text extends Renderable {
|
|
|
413
410
|
* @memberOf me.Text.prototype
|
|
414
411
|
* @function
|
|
415
412
|
* @param {me.CanvasRenderer|me.WebGLRenderer} renderer Reference to the destination renderer instance
|
|
416
|
-
* @param {
|
|
417
|
-
* @param {
|
|
418
|
-
* @param {
|
|
413
|
+
* @param {string} [text]
|
|
414
|
+
* @param {number} [x]
|
|
415
|
+
* @param {number} [y]
|
|
416
|
+
* @param {boolean} [stroke=false] draw stroke the the text if true
|
|
419
417
|
*/
|
|
420
418
|
draw(renderer, text, x, y, stroke) {
|
|
421
419
|
// "hacky patch" for backward compatibilty
|
|
@@ -478,9 +476,9 @@ class Text extends Renderable {
|
|
|
478
476
|
* @memberOf me.Text.prototype
|
|
479
477
|
* @function
|
|
480
478
|
* @param {me.CanvasRenderer|me.WebGLRenderer} renderer Reference to the destination renderer instance
|
|
481
|
-
* @param {
|
|
482
|
-
* @param {
|
|
483
|
-
* @param {
|
|
479
|
+
* @param {string} text
|
|
480
|
+
* @param {number} x
|
|
481
|
+
* @param {number} y
|
|
484
482
|
*/
|
|
485
483
|
drawStroke(renderer, text, x, y) {
|
|
486
484
|
this.draw(renderer, text, x, y, true);
|
package/src/tweens/easing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tween.js - Licensed under the MIT license
|
|
3
|
-
* https://github.com/tweenjs/tween.js
|
|
4
|
-
*/
|
|
2
|
+
* Tween.js - Licensed under the MIT license
|
|
3
|
+
* https://github.com/tweenjs/tween.js
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
/* eslint-disable quotes, keyword-spacing, comma-spacing, no-return-assign */
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* </p>
|
|
43
43
|
* @public
|
|
44
44
|
* @constant
|
|
45
|
-
* @
|
|
45
|
+
* @enum {Function}
|
|
46
46
|
* @name Easing
|
|
47
47
|
* @memberOf me.Tween
|
|
48
48
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tween.js - Licensed under the MIT license
|
|
3
|
-
* https://github.com/tweenjs/tween.js
|
|
4
|
-
*/
|
|
2
|
+
* Tween.js - Licensed under the MIT license
|
|
3
|
+
* https://github.com/tweenjs/tween.js
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Interpolation Function :<br>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* </p>
|
|
13
13
|
* @public
|
|
14
14
|
* @constant
|
|
15
|
-
* @
|
|
15
|
+
* @enum {Function}
|
|
16
16
|
* @name Interpolation
|
|
17
17
|
* @memberOf me.Tween
|
|
18
18
|
*/
|
package/src/tweens/tween.js
CHANGED
|
@@ -5,9 +5,9 @@ import { Easing } from "./easing.js";
|
|
|
5
5
|
import { Interpolation } from "./interpolation.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Tween.js - Licensed under the MIT license
|
|
9
|
-
* https://github.com/tweenjs/tween.js
|
|
10
|
-
*/
|
|
8
|
+
* Tween.js - Licensed under the MIT license
|
|
9
|
+
* https://github.com/tweenjs/tween.js
|
|
10
|
+
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @classdesc
|
|
@@ -25,7 +25,7 @@ import { Interpolation } from "./interpolation.js";
|
|
|
25
25
|
* @class Tween
|
|
26
26
|
* @memberOf me
|
|
27
27
|
* @constructor
|
|
28
|
-
* @param {
|
|
28
|
+
* @param {object} object object on which to apply the tween
|
|
29
29
|
* @example
|
|
30
30
|
* // add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
|
|
31
31
|
* tween = new me.Tween(myObject.pos).to({
|
|
@@ -124,15 +124,16 @@ class Tween {
|
|
|
124
124
|
* @memberOf me.Tween
|
|
125
125
|
* @public
|
|
126
126
|
* @function
|
|
127
|
-
* @param {
|
|
128
|
-
* @param {
|
|
129
|
-
* @param {
|
|
127
|
+
* @param {object} properties hash of properties
|
|
128
|
+
* @param {object|number} [options] object of tween properties, or a duration if a numeric value is passed
|
|
129
|
+
* @param {number} [options.duration] tween duration
|
|
130
130
|
* @param {me.Tween.Easing} [options.easing] easing function
|
|
131
|
-
* @param {
|
|
132
|
-
* @param {
|
|
133
|
-
* @param {
|
|
131
|
+
* @param {number} [options.delay] delay amount expressed in milliseconds
|
|
132
|
+
* @param {boolean} [options.yoyo] allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops.
|
|
133
|
+
* @param {number} [options.repeat] amount of times the tween should be repeated
|
|
134
134
|
* @param {me.Tween.Interpolation} [options.interpolation] interpolation function
|
|
135
|
-
* @param {
|
|
135
|
+
* @param {boolean} [options.autoStart] allow this tween to start automatically. Otherwise call me.Tween.start().
|
|
136
|
+
* @returns {me.Tween} this instance for object chaining
|
|
136
137
|
*/
|
|
137
138
|
to( properties, options ) {
|
|
138
139
|
|
|
@@ -157,7 +158,6 @@ class Tween {
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
return this;
|
|
160
|
-
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
@@ -166,6 +166,8 @@ class Tween {
|
|
|
166
166
|
* @memberOf me.Tween
|
|
167
167
|
* @public
|
|
168
168
|
* @function
|
|
169
|
+
* @param {number} [time] the current time when the tween was started
|
|
170
|
+
* @returns {me.Tween} this instance for object chaining
|
|
169
171
|
*/
|
|
170
172
|
start( time = timer.getTime() ) {
|
|
171
173
|
|
|
@@ -203,7 +205,6 @@ class Tween {
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
return this;
|
|
206
|
-
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
/**
|
|
@@ -212,6 +213,7 @@ class Tween {
|
|
|
212
213
|
* @memberOf me.Tween
|
|
213
214
|
* @public
|
|
214
215
|
* @function
|
|
216
|
+
* @returns {me.Tween} this instance for object chaining
|
|
215
217
|
*/
|
|
216
218
|
stop() {
|
|
217
219
|
// remove the tween from the world container
|
|
@@ -225,7 +227,8 @@ class Tween {
|
|
|
225
227
|
* @memberOf me.Tween
|
|
226
228
|
* @public
|
|
227
229
|
* @function
|
|
228
|
-
* @param {
|
|
230
|
+
* @param {number} amount delay amount expressed in milliseconds
|
|
231
|
+
* @returns {me.Tween} this instance for object chaining
|
|
229
232
|
*/
|
|
230
233
|
delay( amount ) {
|
|
231
234
|
|
|
@@ -240,7 +243,8 @@ class Tween {
|
|
|
240
243
|
* @memberOf me.Tween
|
|
241
244
|
* @public
|
|
242
245
|
* @function
|
|
243
|
-
* @param {
|
|
246
|
+
* @param {number} times amount of times the tween should be repeated
|
|
247
|
+
* @returns {me.Tween} this instance for object chaining
|
|
244
248
|
*/
|
|
245
249
|
repeat( times ) {
|
|
246
250
|
|
|
@@ -257,7 +261,8 @@ class Tween {
|
|
|
257
261
|
* @public
|
|
258
262
|
* @function
|
|
259
263
|
* @see me.Tween#repeat
|
|
260
|
-
* @param {
|
|
264
|
+
* @param {boolean} yoyo
|
|
265
|
+
* @returns {me.Tween} this instance for object chaining
|
|
261
266
|
*/
|
|
262
267
|
yoyo( yoyo ) {
|
|
263
268
|
|
|
@@ -272,7 +277,8 @@ class Tween {
|
|
|
272
277
|
* @memberOf me.Tween
|
|
273
278
|
* @public
|
|
274
279
|
* @function
|
|
275
|
-
* @param {me.Tween.Easing}
|
|
280
|
+
* @param {me.Tween.Easing} easing easing function
|
|
281
|
+
* @returns {me.Tween} this instance for object chaining
|
|
276
282
|
*/
|
|
277
283
|
easing( easing ) {
|
|
278
284
|
if (typeof easing !== "function") {
|
|
@@ -280,7 +286,6 @@ class Tween {
|
|
|
280
286
|
}
|
|
281
287
|
this._easingFunction = easing;
|
|
282
288
|
return this;
|
|
283
|
-
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
/**
|
|
@@ -289,7 +294,8 @@ class Tween {
|
|
|
289
294
|
* @memberOf me.Tween
|
|
290
295
|
* @public
|
|
291
296
|
* @function
|
|
292
|
-
* @param {me.Tween.Interpolation}
|
|
297
|
+
* @param {me.Tween.Interpolation} interpolation interpolation function
|
|
298
|
+
* @returns {me.Tween} this instance for object chaining
|
|
293
299
|
*/
|
|
294
300
|
interpolation( interpolation ) {
|
|
295
301
|
this._interpolationFunction = interpolation;
|
|
@@ -302,9 +308,10 @@ class Tween {
|
|
|
302
308
|
* @memberOf me.Tween
|
|
303
309
|
* @public
|
|
304
310
|
* @function
|
|
305
|
-
* @param {me.Tween} chainedTween Tween to be chained
|
|
311
|
+
* @param {...me.Tween} chainedTween Tween(s) to be chained
|
|
312
|
+
* @returns {me.Tween} this instance for object chaining
|
|
306
313
|
*/
|
|
307
|
-
chain() {
|
|
314
|
+
chain( chainedTween ) {
|
|
308
315
|
this._chainedTweens = arguments;
|
|
309
316
|
return this;
|
|
310
317
|
}
|
|
@@ -316,9 +323,10 @@ class Tween {
|
|
|
316
323
|
* @public
|
|
317
324
|
* @function
|
|
318
325
|
* @param {Function} onStartCallback callback
|
|
326
|
+
* @returns {me.Tween} this instance for object chaining
|
|
319
327
|
*/
|
|
320
|
-
onStart(
|
|
321
|
-
this._onStartCallback =
|
|
328
|
+
onStart( onStartCallback ) {
|
|
329
|
+
this._onStartCallback = onStartCallback;
|
|
322
330
|
return this;
|
|
323
331
|
}
|
|
324
332
|
|
|
@@ -329,9 +337,10 @@ class Tween {
|
|
|
329
337
|
* @public
|
|
330
338
|
* @function
|
|
331
339
|
* @param {Function} onUpdateCallback callback
|
|
340
|
+
* @returns {me.Tween} this instance for object chaining
|
|
332
341
|
*/
|
|
333
|
-
onUpdate(
|
|
334
|
-
this._onUpdateCallback =
|
|
342
|
+
onUpdate( onUpdateCallback ) {
|
|
343
|
+
this._onUpdateCallback = onUpdateCallback;
|
|
335
344
|
return this;
|
|
336
345
|
}
|
|
337
346
|
|
|
@@ -342,9 +351,10 @@ class Tween {
|
|
|
342
351
|
* @public
|
|
343
352
|
* @function
|
|
344
353
|
* @param {Function} onCompleteCallback callback
|
|
354
|
+
* @returns {me.Tween} this instance for object chaining
|
|
345
355
|
*/
|
|
346
|
-
onComplete(
|
|
347
|
-
this._onCompleteCallback =
|
|
356
|
+
onComplete( onCompleteCallback ) {
|
|
357
|
+
this._onCompleteCallback = onCompleteCallback;
|
|
348
358
|
return this;
|
|
349
359
|
};
|
|
350
360
|
|
package/src/utils/agent.js
CHANGED
|
@@ -17,9 +17,9 @@ var vendors = [ "ms", "MS", "moz", "webkit", "o" ];
|
|
|
17
17
|
* @public
|
|
18
18
|
* @name prefixed
|
|
19
19
|
* @function
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @
|
|
20
|
+
* @param {string} name Property name
|
|
21
|
+
* @param {object} [obj=window] Object or element reference to access
|
|
22
|
+
* @returns {string} Value of property
|
|
23
23
|
* @memberOf me.utils.agent
|
|
24
24
|
*/
|
|
25
25
|
export function prefixed(name, obj) {
|
|
@@ -43,10 +43,10 @@ export function prefixed(name, obj) {
|
|
|
43
43
|
* @public
|
|
44
44
|
* @name setPrefixed
|
|
45
45
|
* @function
|
|
46
|
-
* @param {
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {
|
|
49
|
-
* @
|
|
46
|
+
* @param {string} name Property name
|
|
47
|
+
* @param {string} value Property value
|
|
48
|
+
* @param {object} [obj=window] Object or element reference to access
|
|
49
|
+
* @returns {boolean} true if one of the vendor-prefixed property was found
|
|
50
50
|
* @memberOf me.utils.agent
|
|
51
51
|
*/
|
|
52
52
|
export function setPrefixed(name, value, obj) {
|
|
@@ -64,6 +64,7 @@ export function setPrefixed(name, value, obj) {
|
|
|
64
64
|
obj[name] = value;
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
|
-
return false;
|
|
68
67
|
});
|
|
68
|
+
|
|
69
|
+
return false;
|
|
69
70
|
};
|