You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of Phaser 3.60, when adding particles in the new format, using a multi-atlas, sometimes the wrong pixels would be rendered.
I've already found why this happens, here's an explanation:
The pixels are taken from the wrong atlas in the multi-atlas.
The reason this happens is that the sourceIndex of the frame is ignored.
The reason that the sourceIndex in the frame is ignored, is that in the new format the texture is internally set without the frame by calling setTexture(texture) in the ParticleEmitter's constructor.
This causes the emitter's texture to have as its frame the firstFrame, which would always have a sourceIndex 0, instead of the sourceIndex specific to the frame that is defined in the ParticleEmitter's config.
Workaround:
Calling setFrame(frameName) again fixes the issue, see example below.
Example Test Code
classExampleextendsPhaser.Scene{preload(){this.load.path='assets/atlas/';this.load.multiatlas('megaset','tp3-multi-atlas.json');}create(){// Good - This frame from the 1st atlas would be displayed correctlythis.add.image(40,60,'megaset','diamond')// Good - This frame from the 2nd atlas would be displayed correctlythis.add.image(80,60,'megaset','gem')// Good - These particles of a frame from the 1st atlas would be displayed correctlythis.add.particles(40,200,'megaset',{frame: 'diamond'});// Bad - These particles of a frame from the 2nd atlas would be displayed incorrectlythis.add.particles(80,200,'megaset',{frame: 'gem'});// Workaroundthis.add.particles(40,340,'megaset',{frame: 'diamond'}).setFrame('diamond');this.add.particles(80,340,'megaset',{frame: 'gem'}).setFrame('gem');}}
Example output:
The text was updated successfully, but these errors were encountered:
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
Version
Description
As of Phaser 3.60, when adding particles in the new format, using a multi-atlas, sometimes the wrong pixels would be rendered.
I've already found why this happens, here's an explanation:
The pixels are taken from the wrong atlas in the multi-atlas.
The reason this happens is that the
sourceIndex
of the frame is ignored.The reason that the
sourceIndex
in the frame is ignored, is that in the new format the texture is internally set without the frame by callingsetTexture(texture)
in theParticleEmitter
's constructor.This causes the emitter's texture to have as its frame the
firstFrame
, which would always have asourceIndex
0, instead of thesourceIndex
specific to the frame that is defined in theParticleEmitter
's config.Workaround:
Calling
setFrame(frameName)
again fixes the issue, see example below.Example Test Code
Example output:
The text was updated successfully, but these errors were encountered: