Garry3001

Members
  • Content Count

    9
  • Joined

  • Last visited

  1. Very nice game but it does slow down even on a new Macbook Pro. I'm very interested to hear if and how you manage to improve the performance.
  2. Thanks again, it is well explained via that link. So I'm back to finding a way of plotting many thousands of pixels with working alpha as quickly as possible, though this is straying from the original topic now. The most promising answer I had in the other thread was to use getpixel and setpixel with manually adding the RGB values. I haven't tried that, but It's far easier in pure Javascript so maybe I should just stick to the usual games stuff in Phaser.
  3. Thanks for the suggestion, though I can't find any way to apply alpha with renderdraw. There also turned out to be a limit on sprite numbers, so I may have to give up on Phaser for this.
  4. I'm trying to plot pixels with alpha, for mathematical graphics plots. I'd like it as fast as possible and as many pixels per frame as possible. I know it's not the ideal use case for Phaser, but I do love how Phaser makes it very easy to add all the user interface and have it working on Android+iPhones of various sizes.
  5. Thanks! Yes the limit is on the number of drawRect() calls. I guess it's a memory buffer limit. Any ideas about how to force the screen update to empty the buffer again? I could then do that every 10000 loops or so. I tried using lines as an alternative instead but sadly I can't make single pixels with those, unless I'm missing something? I am going to try next with sprites though I expect they're a bit slower.
  6. Ok, here's an example. Try changing the 1000 iterations in the first loop to 10000 for a strange result, and then to 20000 for an even more strange result. var i; function create() { graphics = game.add.graphics(0, 0); graphics.beginFill(0xFFFFFF); for (i = 1; i < 1000; i++) { x = Math.random()*300; y = Math.random()*300; graphics.drawRect(x, y, 1, 1); } for (i = 1; i < 30000; i++) { x = (Math.random()*300)+400; y = Math.random()*300; graphics.drawRect(x, y, 1, 1); } } Sometimes the loop limit seems to be about 32k, but other times it's different. This is completely inconsistent and really annoying! I understand the reasons for protection due to the silly browsers crashing on infinite loops, but it should be documented how to bypass it for those with genuine need.
  7. Thanks for your help with this. I found two methods of achieving this that seem to work well. Hopefully this will be useful to others, and please feel free to post any tested improved alternatives. A) graphics.lineStyle(0); graphics.beginFill(colour, alpha); graphics.drawRect(x, y, 1, 1); B) game.load.image('spriteimage', pixelimageurl); mysprite = game.make.sprite(0, 0, 'spriteimage'); mysprite.anchor.set(0.5); mysprite.alpha = alpha; bmd = game.add.bitmapData(game.width, game.height); bmd.addToWorld(); bmd.smoothed = false; bmd.draw(mysprite, x, y);
  8. Hi Sorry if this is in the docs somewhere, but I couldn't find it. Could someone please tell me if Phaser (or possibly Brackets) is deliberately limiting the size of my loops, as I can't seem to get them to work over about 32000 iterations. I did notice that JSbin has something called "loop protection" but offers a code to turn it off. Is there a way to do this in Phaser?
  9. Hi I'm having trouble with setpixel32, which according to the docs here (http://phaser.io/docs/2.4.8/Phaser.BitmapData.html#setPixel) can have an alpha value as the 6th argument. However when I try this it just plots over whatever is underneath with a fixed level instead of adding to it. Here is a jsbin to demonstrate the issue (using Phaser 2.4.8): http://jsbin.com/repewekopa/1/edit?html,js,output You'll notice that the alpha works fine with drawing a sprite to the bitmap, but if you substitute "bmd.draw(star, x, y);" with "bmd.setPixel32(x, y, 255, 255, 255, 77);" you'll see that you can only draw a uniform grey colour instead of having it build up as intended. Can anyone please tell me what I'm doing wrong, or if this is something that isn't possible with this method? As an extension question, is there any other faster method of plotting pixels with alpha?