General

Members
  • Content count

    7
  • Joined

  • Last visited

About General

  • Rank
    Newbie
  • Birthday 12/06/1984

Contact Methods

  • Website URL
    http://smartflashgames.blogspot.com/
  • Twitter
    cardswars
  • Skype
    generalcfr

Profile Information

  • Gender
    Male
  1. Great concept! So, you made a server on NodeJS and you are hosting it on Azure, right?
  2. Comparing performance of Phaser 2.0.7 and 2.3.0

    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.
  3. 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 2. Running Phaser 2.0.7 in WebGL mode https://dl.dropboxusercontent.com/u/22620118/test/3/sandbox207webgl.html 3. Running Phaser 2.3.0 in Canvas mode https://dl.dropboxusercontent.com/u/22620118/test/3/sandbox230canvas.html 4. Running Phaser 2.3.0 in WebGL mode https://dl.dropboxusercontent.com/u/22620118/test/3/sandbox230webgl.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.
  4. Thank you very much, this worked well! While I had troubles with internet connection I compared the performance of different ways to show the graphics. BitmapData.copyPixels vs BitmapData.draw vs simple sprites vs RenderTexture.renderXY. https://dl.dropboxusercontent.com/u/22620118/PhaserTesting/sandbox.html The game's update function runs one of the functions: useCopyPixels(), useDraw(), useRender() or useSprites(). Here's their code: function useCopyPixels() { //console.log('useCopyPixels '+num); bmd.clear(); //that's the bitmapdata used to draw the game's picture for (var i=0; i<num; i++){ var x = Math.random()*900; var y = Math.random()*700; bmd.copyPixels(sprBMD, sprRct,x, y);//sprBMD is a BitmapData created once, the sprite is drawn onto it. sprRct is a Rectangle of this bitmapData } bmd.dirty = true; } function useDraw() { //console.log('useDraw '+num); 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 is a Sprite which is created once as the game starts. } bmd.dirty = true; } function useRender() { //console.log('useRender '+num); for (var i=0; i<num; i++){ var x = Math.random()*900; var y = Math.random()*700; bmd2.renderXY(spr, x, y, i==0);//bmd2 is an RenderTexture created once as the game starts } } function useSprites() { //console.log('useSprites '+num); for (var i=0; i<num; i++){ var x = Math.random()*900; var y = Math.random()*700; sprites[i].x = x; sprites[i].y = y; //here we have simply sprites in a group on the stage. } }I measure the times between 2 game.render calls, 2 game.update calls and between the beginning and the ending of the game's update call. It appears that on the desktop copyPixels, draw and simply moving the sprites work at almost the same speed, but on mobile devices (Lenovo A850 and iPad2) copyPixes is almost twice faster. What results will you get, I wonder? And could you, please, also, check, did I miss any possibilities for optimisation in the drawing functions code?
  5. Thank you. But I tried to call content = this.game.add.group();//also adding sprites to contentcontent.cacheAsBitmap = true;FadeBMD =this.game.add.bitmapData(800,600);FadeBMD.draw(content, 100, 100);and I got this error: Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.
  6. Thank you very much! Exploring Phaser I encountered one more question to ask (not sure, whether should I create a separate thread for it, but it's also about AS3->Phaser migration). In AS3 I used to make a fading screen effect in this way: 1. Draw the stage to BitmapData. 2. Add a Bitmap from this BitmapData to the stage and start tweening it to alpha = 0 3. Add new game elements on the stage below the bitmap. I wonder, is there a way to draw a group to BitmapData in phaser? Or, at least, draw a Phaser.Text to Phaser.BitmapData? Or is there any other way to make a "screenshot" of the current game screen in Phaser?
  7. Hello! I'm migrating from AS3 to HTML5 and decided to use Phaser. That's great, many thanks for creating it! I have a question about organizing the MouseDown event listener. Let's say I have 100 sprites on the screen, and if the player click on any of them, the sprite's data should be traced. In AS3 adding event listener to each of the sprites I could do: stage.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);......private function onMDown(e:MouseEvent):void{ if (e.target is Sprite){ trace("you clicked on: "+(e.target as Sprite).name); }}Is there such a way in Phaser? I understand, that when creating these sprites in Phaser I have to do: for (var i=0; i<100; i++){ var spr = game.add.sprite(Math.random()*600,Math.random()*400,'PIC_SPRITE'); spr.name = 'Sprite'+i; spr.inputEnabled = true; spr.input.start(0, true); spr.events.onInputDown.add(onMDown, this);}...function onMDown(item, pointer){ console.log('you clicked on '+item.name);}So, I wonder, do I really need to add onInputDown to each sprite? Perhaps, the same effect could be achieved by adding a single function to game.input.onDown, like I did in AS3 adding a single function to stage onMouseDown?