@vpmedia/phaser 1.0.35 → 1.0.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -59,32 +59,6 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
59
59
  return data;
60
60
  }
61
61
 
62
- /**
63
- *
64
- * @param {object} game TBD
65
- * @param {object} json TBD
66
- * @returns {object} TBD
67
- */
68
- export function JSONData(game, json) {
69
- // Malformed?
70
- if (!json.frames) {
71
- return null;
72
- }
73
- // Let's create some frames then
74
- const data = new FrameData();
75
- // By this stage frames is a fully parsed array
76
- const frames = json.frames;
77
- let newFrame;
78
- for (let i = 0; i < frames.length; i += 1) {
79
- newFrame = data.addFrame(new Frame(i, frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename));
80
- if (frames[i].trimmed) {
81
- newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h);
82
- }
83
- }
84
- return data;
85
-
86
- }
87
-
88
62
  /**
89
63
  *
90
64
  * @param {object} game TBD
@@ -8,7 +8,7 @@ import BaseTexture from '../display/webgl/base_texture';
8
8
  import Signal from './signal';
9
9
  import Frame from './frame';
10
10
  import FrameData from './frame_data';
11
- import { JSONData, JSONDataHash } from './animation_parser';
11
+ import { JSONDataHash } from './animation_parser';
12
12
  import { jsonBitmapFont, xmlBitmapFont } from './loader_parser';
13
13
 
14
14
  export const CANVAS = 1;
@@ -113,12 +113,7 @@ export default class {
113
113
  data,
114
114
  base: new BaseTexture(data),
115
115
  };
116
- if (Array.isArray(atlasData.frames)) {
117
- // Let's just work it out from the frames array
118
- obj.frameData = JSONData(this.game, atlasData, key);
119
- } else {
120
- obj.frameData = JSONDataHash(this.game, atlasData, key);
121
- }
116
+ obj.frameData = JSONDataHash(this.game, atlasData, key);
122
117
  this._cache.image[key] = obj;
123
118
  this._resolveURL(url, obj);
124
119
  }
@@ -96,5 +96,4 @@ export const ROPE = 20; // deprecated
96
96
  export const CREATURE = 27; // deprecated
97
97
  export const PENDING_ATLAS = -1;
98
98
  // sprite sheet atlas
99
- export const TEXTURE_ATLAS_JSON_ARRAY = 0;
100
99
  export const TEXTURE_ATLAS_JSON_HASH = 1;
@@ -6,17 +6,13 @@
6
6
  import Signal from './signal';
7
7
  import Rectangle from '../geom/rectangle';
8
8
  import { canPlayAudio } from './device_util';
9
- import { TEXTURE_ATLAS_JSON_ARRAY, TEXTURE_ATLAS_JSON_HASH } from './const';
10
-
11
- export const TILED_JSON = 6;
12
- export const TILEMAP_CSV = 7;
9
+ import { TEXTURE_ATLAS_JSON_HASH } from './const';
13
10
 
14
11
  export default class {
15
12
 
16
13
  constructor(game) {
17
14
  this.game = game;
18
15
  this.cache = game.cache;
19
- this.resetLocked = false;
20
16
  this.isLoading = false;
21
17
  this.hasLoaded = false;
22
18
  this.preloadSprite = null;
@@ -100,9 +96,6 @@ export default class {
100
96
  }
101
97
 
102
98
  reset(hard, clearEvents = false) {
103
- if (this.resetLocked) {
104
- return;
105
- }
106
99
  if (hard) {
107
100
  this.preloadSprite = null;
108
101
  }
@@ -232,22 +225,10 @@ export default class {
232
225
  return this.addToFileList('json', key, url, undefined, overwrite, '.json');
233
226
  }
234
227
 
235
- shader(key, url, overwrite) {
236
- return this.addToFileList('shader', key, url, undefined, overwrite, '.frag');
237
- }
238
-
239
228
  xml(key, url, overwrite) {
240
229
  return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
241
230
  }
242
231
 
243
- script(key, url, callback = false, callbackContext = this) {
244
- return this.addToFileList('script', key, url, { syncPoint: true, callback, callbackContext }, false, '.js');
245
- }
246
-
247
- binary(key, url, callback = false, callbackContext = this) {
248
- return this.addToFileList('binary', key, url, { callback, callbackContext }, false, '.bin');
249
- }
250
-
251
232
  spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
252
233
  return this.addToFileList('spritesheet', key, url, { frameWidth, frameHeight, frameMax, margin, spacing }, false, '.png');
253
234
  }
@@ -278,12 +259,6 @@ export default class {
278
259
  return this;
279
260
  }
280
261
 
281
- tilemap() {
282
- // TODO
283
- console.warn('loader.tilemap() is not implemented');
284
- return this;
285
- }
286
-
287
262
  bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
288
263
  if (textureURL === undefined || textureURL === null) {
289
264
  textureURL = key + '.png';
@@ -311,20 +286,7 @@ export default class {
311
286
  return this;
312
287
  }
313
288
 
314
- atlasJSONArray(key, textureURL, atlasURL, atlasData) {
315
- return this.atlas(key, textureURL, atlasURL, atlasData, TEXTURE_ATLAS_JSON_ARRAY);
316
- }
317
-
318
- atlasJSONHash(key, textureURL, atlasURL, atlasData) {
319
- return this.atlas(key, textureURL, atlasURL, atlasData, TEXTURE_ATLAS_JSON_HASH);
320
- }
321
-
322
- atlasXML() {
323
- // TODO
324
- console.warn('loader.atlasXML() is not implemented');
325
- }
326
-
327
- atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_ARRAY) {
289
+ atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
328
290
  if (textureURL === undefined || textureURL === null) {
329
291
  textureURL = key + '.png';
330
292
  }
@@ -335,9 +297,6 @@ export default class {
335
297
  if (atlasURL) {
336
298
  this.addToFileList('textureatlas', key, textureURL, { atlasURL, format });
337
299
  } else {
338
- if (format === TEXTURE_ATLAS_JSON_ARRAY && typeof atlasData === 'string') {
339
- atlasData = JSON.parse(atlasData);
340
- }
341
300
  this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData, format });
342
301
  }
343
302
  return this;
@@ -525,12 +484,6 @@ export default class {
525
484
  case "xml":
526
485
  this.xml(file.key, file.url, file.overwrite);
527
486
  break;
528
- case "script":
529
- this.script(file.key, file.url, file.callback, pack.callbackContext || this);
530
- break;
531
- case "binary":
532
- this.binary(file.key, file.url, file.callback, pack.callbackContext || this);
533
- break;
534
487
  case "spritesheet":
535
488
  this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
536
489
  break;
@@ -543,22 +496,11 @@ export default class {
543
496
  case "audioSprite":
544
497
  this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
545
498
  break;
546
- case "tilemap":
547
- // TODO
548
- // this.tilemap(file.key, file.url, file.data, Phaser.Tilemap[file.format]);
549
- break;
550
- case "physics":
551
- // TODO
552
- // this.physics(file.key, file.url, file.data, Phaser.Loader[file.format]);
553
- break;
554
499
  case "bitmapFont":
555
500
  this.bitmapFont(file.key, file.textureURL, file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
556
501
  break;
557
502
  case "atlas":
558
- this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, file.format === 'TEXTURE_ATLAS_JSON_HASH' ? TEXTURE_ATLAS_JSON_HASH : TEXTURE_ATLAS_JSON_ARRAY);
559
- break;
560
- case "shader":
561
- this.shader(file.key, file.url, file.overwrite);
503
+ this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
562
504
  break;
563
505
  }
564
506
  }
@@ -599,24 +541,9 @@ export default class {
599
541
  case 'xml':
600
542
  this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.xmlLoadComplete);
601
543
  break;
602
- case 'tilemap':
603
- if (file.format === TILED_JSON) {
604
- this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.jsonLoadComplete);
605
- } else if (file.format === TILEMAP_CSV) {
606
- this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.csvLoadComplete);
607
- } else {
608
- this.asyncComplete(file, 'invalid Tilemap format: ' + file.format);
609
- }
610
- break;
611
544
  case 'text':
612
- case 'script':
613
- case 'shader':
614
- case 'physics':
615
545
  this.xhrLoad(file, this.transformUrl(file.url, file), 'text', this.fileComplete);
616
546
  break;
617
- case 'binary':
618
- this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
619
- break;
620
547
  default:
621
548
  // pass
622
549
  break;
@@ -762,7 +689,7 @@ export default class {
762
689
  } else {
763
690
  // Load the JSON or XML before carrying on with the next file
764
691
  loadNext = false;
765
- if (file.format === TEXTURE_ATLAS_JSON_ARRAY || file.format === TEXTURE_ATLAS_JSON_HASH) {
692
+ if (file.format === TEXTURE_ATLAS_JSON_HASH) {
766
693
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
767
694
  } else {
768
695
  throw new Error('Invalid Texture Atlas format: ' + file.format);
@@ -804,32 +731,6 @@ export default class {
804
731
  file.data = xhr.responseText;
805
732
  this.cache.addText(file.key, file.url, file.data);
806
733
  break;
807
- case 'shader':
808
- file.data = xhr.responseText;
809
- this.cache.addShader(file.key, file.url, file.data);
810
- break;
811
- case 'physics':
812
- this.cache.addPhysicsData(file.key, file.url, JSON.parse(xhr.responseText), file.format);
813
- break;
814
- case 'script':
815
- file.data = document.createElement('script');
816
- file.data.language = 'javascript';
817
- file.data.type = 'text/javascript';
818
- file.data.defer = false;
819
- file.data.text = xhr.responseText;
820
- document.head.appendChild(file.data);
821
- if (file.callback) {
822
- file.data = file.callback.call(file.callbackContext, file.key, xhr.responseText);
823
- }
824
- break;
825
- case 'binary':
826
- if (file.callback) {
827
- file.data = file.callback.call(file.callbackContext, file.key, xhr.response);
828
- } else {
829
- file.data = xhr.response;
830
- }
831
- this.cache.addBinary(file.key, file.data);
832
- break;
833
734
  default:
834
735
  // pass
835
736
  break;
@@ -841,9 +742,7 @@ export default class {
841
742
 
842
743
  jsonLoadComplete(file, xhr) {
843
744
  const data = JSON.parse(xhr.responseText);
844
- if (file.type === 'tilemap') {
845
- this.cache.addTilemap(file.key, file.url, data, file.format);
846
- } else if (file.type === 'bitmapfont') {
745
+ if (file.type === 'bitmapfont') {
847
746
  this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
848
747
  } else if (file.type === 'json') {
849
748
  this.cache.addJSON(file.key, file.url, data);