Serdar Posted December 6, 2015 Share Posted December 6, 2015 Is this a bug or what? Please see the test code and screenshots below. (using Phaser v2.4.4) This code adds circle to both group1 and group2! It should not, should it? function preload() { game.load.image('circle', 'assets/circle.png'); }function create() { var group1 = new Phaser.Group(game); var group2 = new Phaser.Group(game); var mySprite = new Phaser.Sprite(game, 100, 100); group2.add(mySprite); var circle = new Phaser.Sprite(game, 10, 10, 'circle'); circle.width = 32; circle.height = 32; group1.add(circle); }But if I just change the order of group declarations it works as it should be: Only one instance of circle. function preload() { game.load.image('circle', 'assets/circle.png'); }function create() { var group2 = new Phaser.Group(game); var group1 = new Phaser.Group(game); var mySprite = new Phaser.Sprite(game, 100, 100); group2.add(mySprite); var circle = new Phaser.Sprite(game, 10, 10, 'circle'); circle.width = 32; circle.height = 32; group1.add(circle); } Link to comment Share on other sites More sharing options...
drhayes Posted December 7, 2015 Share Posted December 7, 2015 Can you make this happen on jsbin or codepen? Link to comment Share on other sites More sharing options...
Serdar Posted December 7, 2015 Author Share Posted December 7, 2015 This must be a bug. Duplicate sprite in v2.4.4: http://codepen.io/anon/pen/rxayzYSame code works fine in v2.4.3: http://codepen.io/anon/pen/vLExzo Link to comment Share on other sites More sharing options...
drhayes Posted December 8, 2015 Share Posted December 8, 2015 The code you're showing in the CodePen is different than what you're highlighting. And I'm not quite sure what the bug is here? In 2.4.3 it looks like since you didn't give it a texture it's not drawing anything; in 2.4.4 it looks like it's defaulting to missing texture unless you explicitly pass in null. Is that the bug you're talking about? How do you know your circle sprite is in both groups? Link to comment Share on other sites More sharing options...
Serdar Posted December 8, 2015 Author Share Posted December 8, 2015 No, it's the exact same code! Compare the create and preload functions. You know, CodePen doesn't let you load PNG assets from another domain. But it doesn't matter at all: This is not the bug I am talking about. Just notice in one version there is only 1 green rectangle (drawn in place of the actual PNG) and 2 in the other. Forget about the code here, just compare 2 CodePen pages. Exact same code, different results for v2.4.3 and v2.4.4. Here they are again: Duplicate sprite in v2.4.4: http://codepen.io/anon/pen/rxayzYSame code works fine in v2.4.3: http://codepen.io/anon/pen/vLExzo How do you know your circle sprite is in both groups? Just wait CodePen finishes rendering if you don't see any green rectangles. Link to comment Share on other sites More sharing options...
Serdar Posted December 8, 2015 Author Share Posted December 8, 2015 CodePen screenshots. Link to comment Share on other sites More sharing options...
jmp909 Posted December 9, 2015 Share Posted December 9, 2015 trymySprite.baseTexture.skipRender=trueotherwise it uses the default texture for the sprite, which is generally the last texture used i think [update]actually that doesn't work ... skipRender here, just means both texture's dont show, presumably because they're actually sharing the same texturehttp://codepen.io/jmp909/pen/xZGVKy and just to confuse matters, this works now, but only because I've put 2 texture in the cache.. with 1 texture it breaks as you mentionhttp://codepen.io/jmp909/pen/adONdQ i guess it's a bug then Link to comment Share on other sites More sharing options...
Recommended Posts