tralala Posted October 5, 2017 Share Posted October 5, 2017 Hi. I'm new at programming and Phaser and i need a bit of help. Im having array of sprites, and i need to set each one of the elements on different position on my game. Can you tell me how can i do that with some short example pls? Link to comment Share on other sites More sharing options...
samid737 Posted October 7, 2017 Share Posted October 7, 2017 If you have a Javascript array of sprites, you can use forEach to distribute sprites randomly using Math.random. The Phaser way is to use A group instead of an array of sprites. It has convenient methods to deal with sprite positioning/alignment/manipulation: Link to comment Share on other sites More sharing options...
samme Posted October 7, 2017 Share Posted October 7, 2017 Can also be done with group.scatter(). group.scatter(); // in world.bounds group.scatter({x: 0, y: 0, width: 100, height: 100}); // in smaller area Link to comment Share on other sites More sharing options...
Recommended Posts