phaser icon indicating copy to clipboard operation
phaser copied to clipboard

I having problems with bringToTop

Open agar3s opened this issue 8 years ago • 2 comments

https://github.com/photonstorm/phaser/blob/master/src/utils/array/BringToTop.js#L23 When you try to bring to the top the second element, the element stills in the same position.

I just made a small change to replace: if (currentIndex !== -1 && currentIndex < array.length - 2) for if (currentIndex !== -1 && currentIndex < array.length - 1)

It works, but I want to know if there is any decision behind this, I read that the previous implementation used and it doesn't have this '-2'.

agar3s avatar May 11 '18 16:05 agar3s

I ran into this issue too. As a workaround I called bringToTop on a couple of other sprites that I don't care about first. That changes the position of the sprite I want and bringToTop will then work.

patricksheedy avatar May 14 '18 20:05 patricksheedy

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.

photonstorm avatar May 15 '18 07:05 photonstorm