Search the Community
Showing results for tags 'SpriteBatch'.
-
Not sure if here's the best place for this but since it is not a bug etc I avoided opening an issue on github I stumbled upon some odd rotation code in phaser while reading https://phaser.io/tutorials/advanced-rendering-tutorial/part7 From src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js and src/pixi/display/Sprite.js // Rotate matrix by 90 degrees // We use precalculated values for sine and cosine of rad(90) a = a0 * 6.123233995736766e-17 + -c0; b = b0 * 6.123233995736766e-17 + -d0; c = a0 + c0 * 6.123233995736766e-17; d = b0 + d0 * 6.123233995736766e-17; Ok. Some rotationcode with fancy precalculated values. But: the value given in e-notation is 0.00000000000000006123233995736766 and therefore effectively zero. Which makes sense since this was meant to be the precalculation of cos(rad(90)) - which equals exactly to zero. I suppose the literal resulted from a rounding error when someone typed Math.cos(Math.radians(90)) into a console So a better version would be: // Rotate matrix by 90 degrees a = -c0; b = -d0; c = a0; d = b0; Maybe someone sees this and is willing to fix it on the side...
-
Hey everyone, I'm trying to use SpriteBatch for optimization, and I'm initializing it like this: spriteBatch = new Phaser.SpriteBatch(game, this); But I get the following error on that line: "Uncaught TypeError: undefined is not a function" Am I initializing the spritebatch incorrectly? I would like to avoid game.add if possible. Thanks!
-
I have too many sprites to render at the same time, so i must use the SpriteBatch to improve performance. But i dont know what the difference between 'Group' and 'SpriteBatch' when i want to do the collision detection. I want someone's help. Thanks!
-
I'd like to use SpriteBatch instead of Groups for 2 layers that display up to 64 sprites for a speed boost. However, simply changing Group to SpriteBatch didn't work - I used to be able to tap/click on the sprites, but now that input event doesn't seem to fire. I'm wondering if SpriteBatch disables or disrupts input somehow? Interestingly, the input events are attached to the parent of the SpriteBatch, not the SpriteBatch itself. Thanks -rich
-
Im trying to create a 9 slice style object to render shapes with repeating tiles. SpriteBatch appears to offer the fastest rendering solution but when I add a tiling sprite to a SpriteBatch it fails to repeat the texture even when the tiling sprites width/height dimensions suggest it should. Everything works fine when I instead embed it in a DisplayObjectContainer. Is it possible to have a TilingSprite inside a SpriteBatch or will I need to used a DisplayObjectContainer instead? Another possibility for me would be to manually generate and position sprites inside a SpriteBatch to achieve the same effect. An awkward solution I'd rather avoid but if there's still a performance gain over using a DisplayObjectContainer, its one I'd be forced to use...
-
I'm tuning performance for my game. I'm using SpriteBatches where it is possible. So I have looked at PIXI sources(version 2.2.8) and made next assumptions about SpriteBatch performance: WebGL: Inside each SpriteBatch I should use textures only from one spritesheet. Otherwise on each render WebGLFastSpriteBatch.flush is called which is expensive operation and should be avoided. Canvas: SpriteBatch children can be from different spritesheets it won't affect performance. But we should avoid child rotation because it would call context.setTransform multiple times. Overall: Using sb for canvas improves performance very slightly. For WebGL it gives significant boost. Please correct me if I wrong. Thanks in advance!
- 4 replies
-
- spritebatch
- canvas
-
(and 1 more)
Tagged with:
-
Is it possible use two SripeSheet into PIXI.SpriteBatch ???
- 4 replies
-
- SpriteBatch
- PIXI
-
(and 4 more)
Tagged with:
-
I just grabbed Pixi 1.5 and straight-away I went to test SpriteBatch with my tilemap scroller torture test. the results were not what I expected - I get about half the frame-rate that I get using DispayObjectContainer... so... my question is: are there particular "gotchas" or things I need to watch out for when using SpriteBatch? (all I did was change the DisplayObjectContainer that was I was using to a SpriteBatch. perhaps that isn't such a great idea and there are other factors I need to be aware of?) cheers!
- 12 replies
-
- performance
- SpriteBatch
-
(and 1 more)
Tagged with:
-
Hey guys! If I have a large selection of sprites (tiles) that are owned by a spritebatch - what is the most efficient way of culling them? Currently I am adding / removing from the batch. Is this this the best way? If so, what is the most efficient way of updating the contents of the spritebatch? current I am being lazy and flagging those that are 'to be rendered' and placing them in an array and doing something like: batch.removeAll(); batch.addMultiple(array); is there a quicker way I can do this? Thanks
-
- performance
- culling
-
(and 1 more)
Tagged with:
-
I've been playing with 1.5 and SpriteBatch and using it for particle systems. This is in the context of a side-scrolling-type game, where there is a "root" camera DisplayObjectContainer (DOC) that sets the translation for the POV (inverse of it, actually - when the camera "moves" left, everything visible appears to "move" right etc). the SpriteBatch that holds the particles is a child of the "camera" DOC everything is working great and performance is quite good (on my laptop I can spawn many tens of thousands of particles before the frame-rates starts to drop; obviously not so much on mobile). but I discovered an odd thing. on my iPad mini (1st gen) the particles "stick" with the camera - i.e. they don't move as the camera changes position. this happens in both safari and chrome (but IIRC on iOS they share the javascript engine and maybe more, due to apple's TOS). perhaps it's an issue with the GPU driver. very odd. this works properly on desktop (linux chrome & firefox) and android (nexus 5 and 7). I've entered issue #580 on github to track this - cheers
-
I've got a DisplayObjectContainer with a bunch of sprites, some of which have masks. When checking out the new SpriteBatch it seems that it doesn't respect the masking of its children. Is this a known issue or am I missing something? Here's a quick example demonstrating the issue: http://www.lostdecadegames.com/sandbox/pixi-spritebatch-mask/ The bunnies on the left are children of a DisplayObjectContainer while the maggots on the right are children of a SpriteBatch. A mask which clips half way down the stage is applied to both sets of sprites. And the relevant JavaScript as a gist: https://gist.github.com/geoffb/8944694