Skip to content

Commit b6cc150

Browse files
committed
Game.scratch is a single handy BitmapData instance that can be used as a visual scratch-pad, for off-screen bitmap manipulation (and is used as such by BitmapData itself).
Updated TS defs.
1 parent 87bcb66 commit b6cc150

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Version 2.0.4 - "Mos Shirare" - in development
8888
* Group.resetCursor will reset the Group cursor back to the start of the group, or to the given index value.
8989
* World.wrap will take a game object and if its x/y coordinates fall outside of the world bounds it will be repositioned on the opposite side, for a wrap-around effect.
9090
* Group.classType allows you to change the type of object that Group.create or createMultiple makes to your own custom class.
91+
* Game.scratch is a single handy BitmapData instance that can be used as a visual scratch-pad, for off-screen bitmap manipulation (and is used as such by BitmapData itself).
9192

9293

9394
### Bug Fixes

build/phaser.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,7 @@ declare module Phaser {
17041704
renderType: number;
17051705
rnd: Phaser.RandomDataGenerator;
17061706
scale: Phaser.ScaleManager;
1707+
scratch: Phaser.BitmapData;
17071708
sound: Phaser.SoundManager;
17081709
stage: Phaser.Stage;
17091710
state: Phaser.StateManager;
@@ -1935,6 +1936,7 @@ declare module Phaser {
19351936
angle: number;
19361937
alive: boolean;
19371938
cameraOffset: Phaser.Point;
1939+
classType: any;
19381940
cursor: any;
19391941
enableBody: boolean;
19401942
enableBodyDebug: boolean;
@@ -1959,8 +1961,8 @@ declare module Phaser {
19591961
callbackFromArray(child: Object, callback: Function, length: number): void;
19601962
countDead(): number;
19611963
countLiving(): number;
1962-
create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
1963-
createMultiple(quantity: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
1964+
create(x: number, y: number, key: string, frame?: any, exists?: boolean): any;
1965+
createMultiple(quantity: number, key: string, frame?: any, exists?: boolean): void;
19641966
customSort(sortHandler: Function, context: Object): void;
19651967
destroy(destroyChildren?: boolean, soft?: boolean): void;
19661968
divideAll(property: string, amount: number, checkAlive?: boolean, checkVisible?: boolean): void;

src/core/Game.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
207207
*/
208208
this.particles = null;
209209

210+
/**
211+
* @property {Phaser.BitmapData} scratch - A handy BitmapData scratch-pad that can be used for off-screen bitmap manipulation.
212+
*/
213+
this.scratch = null;
214+
210215
/**
211216
* @property {boolean} stepping - Enable core loop stepping with Game.enableStep().
212217
* @default
@@ -445,6 +450,7 @@ Phaser.Game.prototype = {
445450
this.plugins = new Phaser.PluginManager(this);
446451
this.net = new Phaser.Net(this);
447452
this.debug = new Phaser.Utils.Debug(this);
453+
this.scratch = new Phaser.BitmapData(this, '__root', this.width, this.height);
448454

449455
this.time.boot();
450456
this.stage.boot();

0 commit comments

Comments
 (0)