Skip to content

Commit 33d9b19

Browse files
committed
The Debug canvas is now cleared on State swap.
1 parent 03bd2aa commit 33d9b19

4 files changed

Lines changed: 60 additions & 17 deletions

File tree

README.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
- [Bugs?](#bugs)
2121
- [License](#license)
2222

23-
# Phaser 2.1.0 <a name="about"></a>
23+
<a name="about"></a>
24+
# Phaser 2.1.0
2425

2526
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
2627

@@ -41,7 +42,8 @@ By Richard Davey, [Photon Storm](http://www.photonstorm.com)
4142

4243
![div](http://phaser.io/images/div4.png)
4344

44-
## Welcome to Phaser and What's new in 2.1.0? <a name="whats-new"></a>
45+
<a name="whats-new"></a>
46+
## Welcome to Phaser and What's new in 2.1.0?
4547

4648
Phaser 2.1 is a significant update, bringing literally hundreds of features, fixes and updates to the core framework. It's the result of months of hard work from both the Phaser team and the wonderful community on github and the forums.
4749

@@ -59,7 +61,8 @@ Until then happy coding everyone! And we hope to see you on the forums.
5961

6062
![div](http://phaser.io/images/div1.png)
6163

62-
## Getting Started Guides <a name="getting-started"></a>
64+
<a name="getting-started"></a>
65+
## Getting Started Guides
6366

6467
We have a [Getting Started Guide](http://phaser.io/getting-started-js.php) which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there.
6568

@@ -73,7 +76,8 @@ Finally the list of [community authored Phaser Tutorials](http://www.lessmilk.co
7376

7477
![div](http://phaser.io/images/div2.png)
7578

76-
## Change Log <a name="change-log"></a>
79+
<a name="change-log"></a>
80+
## Change Log
7781

7882
Version 2.1.0 - "Cairhien" - 9th September 2014
7983

@@ -206,6 +210,7 @@ Version 2.1.0 - "Cairhien" - 9th September 2014
206210
* Phaser.Text wouldn't render the text to its local canvas if you passed the text on the constructor and didn't add it to the display list. If a string is given it now updates the local canvas on creation.
207211
* Signal.removeAll would ignore the context parameter and remove all bindings regardless (thanks @alect #1168)
208212
* P2.Body.addCapsule didn't use to pass the radius value through pxm, but now does so you have to specify it in pixels, not meters.
213+
* The Debug canvas is now cleared on State swap.
209214

210215
### p2.js 0.6.0 Changes and New Features
211216

@@ -249,7 +254,8 @@ For details about changes made in previous versions of Phaser see the full Chang
249254

250255
![div](http://phaser.io/images/div3.png)
251256

252-
## How to Build <a name="how-to-build"></a>
257+
<a name="how-to-build"></a>
258+
## How to Build
253259

254260
We provide a fully compiled version of Phaser in the `build` folder, in both plain and minified formats.
255261

@@ -265,13 +271,15 @@ Note: Some of you may not be aware, but the `phaser.min.js` file in the build fo
265271

266272
![div](http://phaser.io/images/div4.png)
267273

268-
## Koding <a name="koding"></a>
274+
<a name="koding"></a>
275+
## Koding
269276

270277
You can [clone the Phaser repo in Koding](https://koding.com/Teamwork?import=https://github.com/photonstorm/phaser/archive/master.zip&c=git1) and then start editing and previewing code right away using their web based VM development system.
271278

272279
![div](http://phaser.io/images/div5.png)
273280

274-
## Bower / NPM <a name="bower"></a>
281+
<a name="bower"></a>
282+
## Bower / NPM
275283

276284
If you use bower you can install phaser with:
277285

@@ -287,7 +295,8 @@ Nice and easy :)
287295

288296
![div](http://phaser.io/images/div6.png)
289297

290-
## CDNJS <a name="cdnjs"></a>
298+
<a name="cdnjs"></a>
299+
## CDNJS
291300

292301
Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
293302

@@ -299,7 +308,8 @@ Or if you prefer you can leave the protocol off, so it works via http and https:
299308

300309
![div](http://phaser.io/images/div1.png)
301310

302-
## Requirements <a name="requirements"></a>
311+
<a name="requirements"></a>
312+
## Requirements
303313

304314
Games created with Phaser require a modern web browser that supports the canvas tag. This includes Internet Explorer 9+, Firefox, Chrome, Safari and Opera. It also works on mobile web browsers including stock Android 2.x browser and above and iOS5 Mobile Safari and above. But as always be aware of browser limitations. Not all features of Phaser work on all browsers.
305315

@@ -313,7 +323,8 @@ Phaser is developed in JavaScript. We've made no assumptions about how you like
313323

314324
If you code with [TypeScript](http://www.typescriptlang.org/) you'll find a comprehensive definitions file inside the `build` folder and tutorials on getting started.
315325

316-
### Build Files and Custom Builds <a name="build-files"></a>
326+
<a name="build-files"></a>
327+
### Build Files and Custom Builds
317328

318329
The `build` folder contains the pre-built packaged versions of Phaser.
319330

@@ -327,7 +338,8 @@ You can create your own custom build of Phaser by looking at the grunt options a
327338

328339
![div](http://phaser.io/images/div3.png)
329340

330-
## Learn By Example <a name="example"></a>
341+
<a name="example"></a>
342+
## Learn By Example
331343

332344
Ever since we started Phaser we've been growing and expanding our extensive set of Examples. Currently over 320 of them!
333345

@@ -351,7 +363,8 @@ You can also browse all [Phaser Examples](http://examples.phaser.io) online.
351363

352364
![div](http://phaser.io/images/div4.png)
353365

354-
## Features <a name="features"></a>
366+
<a name="features"></a>
367+
## Features
355368

356369
**WebGL &amp; Canvas**
357370

@@ -422,7 +435,8 @@ Phaser has been used to create hundreds of games, which receive millions of play
422435

423436
![div](http://phaser.io/images/div6.png)
424437

425-
## Road Map <a name="road-map"></a>
438+
<a name="road-map"></a>
439+
## Road Map
426440

427441
Here are some of the features planned for future releases:
428442

@@ -461,13 +475,15 @@ Phaser 3 has entered the planning stages. Development will not begin until early
461475

462476
![div](http://phaser.io/images/div1.png)
463477

464-
## Mighty Editor - A Visual Phaser Game Editor <a name="mighty-editor"></a>
478+
<a name="mighty-editor"></a>
479+
## Mighty Editor - A Visual Phaser Game Editor
465480

466481
[MightyEditor](http://mightyfingers.com/) is a browser-based visual Phaser game editor. Create your maps with ease, position objects and share them in seconds. It also exports to native Phaser code. Excellent for quickly setting-up levels and scenes.
467482

468483
![div](http://phaser.io/images/div2.png)
469484

470-
## Contributing <a name="contributing"></a>
485+
<a name="contributing"></a>
486+
## Contributing
471487

472488
We now have a full [Contributors Guide][contribute] which goes into the process in more detail, but here are the headlines:
473489

@@ -483,7 +499,8 @@ We now have a full [Contributors Guide][contribute] which goes into the process
483499

484500
![div](http://phaser.io/images/div3.png)
485501

486-
## Bugs? <a name="bugs"></a>
502+
<a name="bugs"></a>
503+
## Bugs?
487504

488505
Please add them to the [Issue Tracker][issues] with as much info as possible, especially source code demonstrating the issue.
489506

@@ -493,7 +510,8 @@ Please add them to the [Issue Tracker][issues] with as much info as possible, es
493510

494511
![div](http://phaser.io/images/div4.png)
495512

496-
## License <a name="license"></a>
513+
<a name="license"></a>
514+
## License
497515

498516
Phaser is released under the [MIT License](http://opensource.org/licenses/MIT).
499517

build/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,6 +5156,7 @@ declare module Phaser {
51565156
pointer(pointer: Phaser.Pointer, hideIfUp?: boolean, downColor?: string, upColor?: string, color?: string): void;
51575157
quadTree(quadtree: Phaser.QuadTree, color?: string): void;
51585158
rectangle(object: Phaser.Rectangle, color?: string, filled?: boolean): void;
5159+
reset(): void;
51595160
soundInfo(sound: Phaser.Sound, x: number, y: number, color?: string): void;
51605161
spriteBounds(sprite: any, color?: string, filled?: boolean): void;
51615162
spriteCoords(sprite: any, x: number, y: number, color?: string): void;

src/core/StateManager.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ Phaser.StateManager.prototype = {
369369

370370
this.game.scale.reset(this._clearWorld);
371371

372+
if (this.game.debug)
373+
{
374+
this.game.debug.reset();
375+
}
376+
372377
if (this._clearWorld)
373378
{
374379
this.game.world.shutdown();

src/utils/Debug.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ Phaser.Utils.Debug.prototype = {
139139

140140
},
141141

142+
/**
143+
* Clears the Debug canvas.
144+
*
145+
* @method Phaser.Utils.Debug#reset
146+
*/
147+
reset: function () {
148+
149+
if (this.context)
150+
{
151+
this.context.clearRect(0, 0, this.game.width, this.game.height);
152+
}
153+
154+
if (this.sprite)
155+
{
156+
PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl);
157+
}
158+
159+
},
160+
142161
/**
143162
* Internal method that resets and starts the debug output values.
144163
*

0 commit comments

Comments
 (0)