iamhaas Posted April 17, 2014 Share Posted April 17, 2014 Is there a method to clone/duplicate a sprite? Link to comment Share on other sites More sharing options...
Herry Posted April 17, 2014 Share Posted April 17, 2014 Is there a method to clone/duplicate a sprite? Yes, I has same question too. Because my Sprite, image, text is by user (alpha, rotate, scale). I want to duplicate it. How to make it ? Thank you so much. Link to comment Share on other sites More sharing options...
kroop Posted June 11, 2014 Share Posted June 11, 2014 Ran into same issue, dunno if this is the right way to do it but seems to do the trickvar spriteB = game.add.sprite(100, 200, spriteA.generateTexture()); Link to comment Share on other sites More sharing options...
lewster32 Posted June 11, 2014 Share Posted June 11, 2014 Cloning is not a simple procedure in JavaScript because of many factors including prototype chains. Your best bet is to create a new sprite and copy the properties you want over to it, i.e.: var sprite1 = game.add.sprite(100, 200, 'player', 0);var sprite1Copy = game.add.sprite(sprite1.x, sprite1.y, sprite1.key, sprite1.frame);You'd then set any other properties you've already set on the original in the same way. If you're going to do this often and have lots of stuff to copy across, creating a function to do this would be the best approach. Link to comment Share on other sites More sharing options...
Recommended Posts