Skip to content

Commit 8b2f1cc

Browse files
committed
Various small fixes
1 parent e002827 commit 8b2f1cc

5 files changed

Lines changed: 89 additions & 90 deletions

File tree

Phaser/gameobjects/Sprite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module Phaser {
229229

230230
if (this.group)
231231
{
232-
//this.group.bringToTop(this);
232+
this.group.bringToTop(this);
233233
}
234234

235235
}

Phaser/loader/Loader.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ module Phaser {
8686
*/
8787
public crossOrigin: string = '';
8888

89+
// If you want to append a URL before the path of any asset you can set this here.
90+
// Useful if you need to allow an asset url to be configured outside of the game code.
91+
// MUST have / on the end of it!
92+
public baseURL: string = '';
93+
8994
public onFileComplete: Phaser.Signal;
9095
public onFileError: Phaser.Signal;
9196
public onLoadStart: Phaser.Signal;
@@ -326,7 +331,7 @@ module Phaser {
326331
file.data.onload = () => this.fileComplete(file.key);
327332
file.data.onerror = () => this.fileError(file.key);
328333
file.data.crossOrigin = this.crossOrigin;
329-
file.data.src = file.url;
334+
file.data.src = this.baseURL + file.url;
330335
break;
331336

332337
case 'audio':
@@ -338,7 +343,7 @@ module Phaser {
338343
// WebAudio or Audio Tag?
339344
if (this.game.sound.usingWebAudio)
340345
{
341-
this._xhr.open("GET", file.url, true);
346+
this._xhr.open("GET", this.baseURL + file.url, true);
342347
this._xhr.responseType = "arraybuffer";
343348
this._xhr.onload = () => this.fileComplete(file.key);
344349
this._xhr.onerror = () => this.fileError(file.key);
@@ -352,7 +357,7 @@ module Phaser {
352357
file.data = new Audio();
353358
file.data.name = file.key;
354359
file.data.preload = 'auto';
355-
file.data.src = file.url;
360+
file.data.src = this.baseURL + file.url;
356361
this.fileComplete(file.key);
357362
}
358363
else
@@ -361,7 +366,7 @@ module Phaser {
361366
file.data.name = file.key;
362367
file.data.onerror = () => this.fileError(file.key);
363368
file.data.preload = 'auto';
364-
file.data.src = file.url;
369+
file.data.src = this.baseURL + file.url;
365370
file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
366371
file.data.load();
367372
}
@@ -371,7 +376,7 @@ module Phaser {
371376
break;
372377

373378
case 'text':
374-
this._xhr.open("GET", file.url, true);
379+
this._xhr.open("GET", this.baseURL + file.url, true);
375380
this._xhr.responseType = "text";
376381
this._xhr.onload = () => this.fileComplete(file.key);
377382
this._xhr.onerror = () => this.fileError(file.key);
@@ -454,7 +459,7 @@ module Phaser {
454459
{
455460
// Load the JSON or XML before carrying on with the next file
456461
loadNext = false;
457-
this._xhr.open("GET", file.atlasURL, true);
462+
this._xhr.open("GET", this.baseURL + file.atlasURL, true);
458463
this._xhr.responseType = "text";
459464

460465
if (file.format == Loader.TEXTURE_ATLAS_JSON_ARRAY)

Phaser/physics/arcade/Body.ts

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -218,89 +218,6 @@ module Phaser.Physics {
218218
return this.position.y - this.oldPosition.y;
219219
}
220220

221-
222-
223-
224-
225-
226-
227-
228-
229-
230-
// MOVE THESE TO A UTIL
231-
232-
public render(context:CanvasRenderingContext2D) {
233-
234-
context.beginPath();
235-
context.strokeStyle = 'rgb(0,255,0)';
236-
context.strokeRect(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight, this.bounds.width, this.bounds.height);
237-
context.stroke();
238-
context.closePath();
239-
240-
// center point
241-
context.fillStyle = 'rgb(0,255,0)';
242-
context.fillRect(this.position.x, this.position.y, 2, 2);
243-
244-
if (this.touching & Phaser.Types.LEFT)
245-
{
246-
context.beginPath();
247-
context.strokeStyle = 'rgb(255,0,0)';
248-
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
249-
context.lineTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
250-
context.stroke();
251-
context.closePath();
252-
}
253-
if (this.touching & Phaser.Types.RIGHT)
254-
{
255-
context.beginPath();
256-
context.strokeStyle = 'rgb(255,0,0)';
257-
context.moveTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
258-
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
259-
context.stroke();
260-
context.closePath();
261-
}
262-
263-
if (this.touching & Phaser.Types.UP)
264-
{
265-
context.beginPath();
266-
context.strokeStyle = 'rgb(255,0,0)';
267-
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
268-
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
269-
context.stroke();
270-
context.closePath();
271-
}
272-
if (this.touching & Phaser.Types.DOWN)
273-
{
274-
context.beginPath();
275-
context.strokeStyle = 'rgb(255,0,0)';
276-
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
277-
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
278-
context.stroke();
279-
context.closePath();
280-
}
281-
282-
}
283-
284-
285-
/**
286-
* Render debug infos. (including name, bounds info, position and some other properties)
287-
* @param x {number} X position of the debug info to be rendered.
288-
* @param y {number} Y position of the debug info to be rendered.
289-
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
290-
*/
291-
public renderDebugInfo(x: number, y: number, color: string = 'rgb(255,255,255)') {
292-
293-
this.sprite.texture.context.fillStyle = color;
294-
this.sprite.texture.context.fillText('Sprite: (' + this.sprite.width + ' x ' + this.sprite.height + ')', x, y);
295-
//this.sprite.texture.context.fillText('x: ' + this._sprite.frameBounds.x.toFixed(1) + ' y: ' + this._sprite.frameBounds.y.toFixed(1) + ' rotation: ' + this._sprite.rotation.toFixed(1), x, y + 14);
296-
this.sprite.texture.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.sprite.transform.rotation.toFixed(0), x, y + 14);
297-
this.sprite.texture.context.fillText('vx: ' + this.velocity.x.toFixed(1) + ' vy: ' + this.velocity.y.toFixed(1), x, y + 28);
298-
this.sprite.texture.context.fillText('acx: ' + this.acceleration.x.toFixed(1) + ' acy: ' + this.acceleration.y.toFixed(1), x, y + 42);
299-
this.sprite.texture.context.fillText('angVx: ' + this.angularVelocity.toFixed(1) + ' angAc: ' + this.angularAcceleration.toFixed(1), x, y + 56);
300-
301-
}
302-
303-
304221
}
305222

306223
}

Phaser/utils/DebugUtils.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,81 @@ module Phaser {
295295

296296
}
297297

298+
/*
299+
public render(context:CanvasRenderingContext2D) {
300+
301+
context.beginPath();
302+
context.strokeStyle = 'rgb(0,255,0)';
303+
context.strokeRect(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight, this.bounds.width, this.bounds.height);
304+
context.stroke();
305+
context.closePath();
306+
307+
// center point
308+
context.fillStyle = 'rgb(0,255,0)';
309+
context.fillRect(this.position.x, this.position.y, 2, 2);
310+
311+
if (this.touching & Phaser.Types.LEFT)
312+
{
313+
context.beginPath();
314+
context.strokeStyle = 'rgb(255,0,0)';
315+
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
316+
context.lineTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
317+
context.stroke();
318+
context.closePath();
319+
}
320+
if (this.touching & Phaser.Types.RIGHT)
321+
{
322+
context.beginPath();
323+
context.strokeStyle = 'rgb(255,0,0)';
324+
context.moveTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
325+
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
326+
context.stroke();
327+
context.closePath();
328+
}
329+
330+
if (this.touching & Phaser.Types.UP)
331+
{
332+
context.beginPath();
333+
context.strokeStyle = 'rgb(255,0,0)';
334+
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
335+
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
336+
context.stroke();
337+
context.closePath();
338+
}
339+
if (this.touching & Phaser.Types.DOWN)
340+
{
341+
context.beginPath();
342+
context.strokeStyle = 'rgb(255,0,0)';
343+
context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
344+
context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
345+
context.stroke();
346+
context.closePath();
347+
}
348+
349+
}
350+
*/
351+
352+
/**
353+
* Render debug infos. (including name, bounds info, position and some other properties)
354+
* @param x {number} X position of the debug info to be rendered.
355+
* @param y {number} Y position of the debug info to be rendered.
356+
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
357+
*/
358+
/*
359+
public renderDebugInfo(x: number, y: number, color: string = 'rgb(255,255,255)') {
360+
361+
this.sprite.texture.context.fillStyle = color;
362+
this.sprite.texture.context.fillText('Sprite: (' + this.sprite.width + ' x ' + this.sprite.height + ')', x, y);
363+
//this.sprite.texture.context.fillText('x: ' + this._sprite.frameBounds.x.toFixed(1) + ' y: ' + this._sprite.frameBounds.y.toFixed(1) + ' rotation: ' + this._sprite.rotation.toFixed(1), x, y + 14);
364+
this.sprite.texture.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.sprite.transform.rotation.toFixed(0), x, y + 14);
365+
this.sprite.texture.context.fillText('vx: ' + this.velocity.x.toFixed(1) + ' vy: ' + this.velocity.y.toFixed(1), x, y + 28);
366+
this.sprite.texture.context.fillText('acx: ' + this.acceleration.x.toFixed(1) + ' acy: ' + this.acceleration.y.toFixed(1), x, y + 42);
367+
this.sprite.texture.context.fillText('angVx: ' + this.angularVelocity.toFixed(1) + ' angAc: ' + this.angularAcceleration.toFixed(1), x, y + 56);
368+
369+
}
370+
*/
371+
372+
298373
}
299374

300375
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Future Plans
3333
* Joypad support.
3434
* Gestures input class.
3535
* Integrate the Advanced Physics system that is 90% ready but needs updating for TypeScript 0.9.1.
36+
* We can streamline the code for a lot of the CanvasRenderer calls re: global ops, alpha, etc.
37+
* Move getOffset inside Phaser.Display.Canvas
3638

3739

3840
ToDo before release

0 commit comments

Comments
 (0)