Jump to content

Comparing performance of Phaser 2.0.7 and 2.3.0


General
 Share

Recommended Posts

Hello!

It seems to me that all the drawing methods work slower in Phaser 2.3.0 than in Phaser 2.0.7. Or I'm using them in a wrong way, Could you, please, check these samples?

in Phaser 2.0.7 I assume there are 4 drawing methods:

1. CopyPixels: copy pixels from a bitmapdata once drawn as the game starts to the screen bitmapdata

		bmd.clear(); //screen BitmapData		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			bmd.copyPixels(sprBMD, sprRct,x, y);//sprBMD - BitmapData with the sprite's graphics//sprRct - Rect defining the sprite's image on the sprite BitmapData		}			bmd.dirty = true;

2. Draw: just use a single copy of a sprite in the memory and draw it to the screen bitmapdata

		bmd.clear();		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			bmd.draw(spr, x, y); //spr - a sprite created once as the game started		}				bmd.dirty = true;

3. Sprites: create as many sprites as they are needed and just change their coordinates

		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			sprites[i].x = x; //sprites are created when the "Sprites" mode is tested and they			sprites[i].y = y; //are all destroyed if another mode is tested		}	

4. Render: using renderXY method od a renderTexture.

		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			bmd2.renderXY(spr, x, y, i==0);		} 

In Phaser 2.3.0. copyPixels method is absent, but 2 new methods appear:

1a. CopyRect: copying rect from a source bitmapData to the screen bitmapData

		bmd.clear();		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			bmd.copyRect(sprBMD, sprRct,x, y);		}			bmd.dirty = true;

5. Copy: use a screen bitmapData method Copy to draw a bitmapData which has a sprite picture.

		bmd.clear();		for (var i=0; i<num; i++){			var x =  Math.random()*900;			var y =  Math.random()*700;			bmd.copy(sprBMD, 0,0,sprRct.width,sprRct.height,x,y);		}			bmd.dirty = true;

So, to summarize, we have:

1. single on-screen BitmapData bmd

2. single on-screen RenderTexture bmd2

3. single in-memory Sprite spr

4. single in-memoty BitmapData sprBMD to which the sprite spr drew itself as the game started.

 

We can (1) copyPixels from sprBMD to bmd or (2) use Draw method of bmd to draw a spr or (3) create multiple sprites like spr on the screen and just change hteir coordinates or (4) use renderXY method of bmd2 to draw spr or (1a) use CopyRect method of bmd to copy the contents of sprBMD to it or (5) use Copy method of bmd to copy the contents of sprBMD to it.

 

Please, check 4 test samples:

 

1. Running Phaser 2.0.7 in Canvas mode

https://dl.dropboxusercontent.com/u/22620118/test/3/sandbox207canvas.html

 

 

 

In each sample you can select a drawing method and number of sprites drawn each frame.

 

Looks like all the drawing methods from 2.3.0 give significantly lower FPS than from 2.0.7 I tested this in Chrome on AMD E2 laptop, on Core i3 PC, in Safari on iPad2 and in Chrome on Lenovo A850 (Android)

 

Perhaps I'm missing some must-dos when mighrating from 2.0.7 to 2.3.0

 

Anyway, please, don't think it's merely criticising Phaser updates, I really much appreciate your work. In fact Phaser helped me enter HTML5 game development and now I just want to help make it even better.

Link to comment
Share on other sites

Sorry, I've just re-read my post and made a correction - my point is that FPS shown in 2.3.0 is almost always lower than in 2.0.7. All the rendering methods (especially related to bitmap drawing and copy pixels) work slower in 2.3.0. And pure sprites movement FPS is almost equal or slightly slower in 2.3.0 than on 2.0.7.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...