glass22 Posted December 28, 2013 Share Posted December 28, 2013 Is there anyway within Phaser to detect if any object will be over lapping if you create a sprite there? Like randomworldX Where there is no unit? Also Is there anyway to get an array/group of all sprite objects currently alive? Link to comment Share on other sites More sharing options...
MisterMaSK Posted December 28, 2013 Share Posted December 28, 2013 Don't know about the first question but for the second one - you can go through a group like this - this.groupName.forEach(function(item) { // do whatever you want with them right here}); Link to comment Share on other sites More sharing options...
rich Posted December 28, 2013 Share Posted December 28, 2013 You'll have to implement your own placement code as it's very game specific, I would suggest that rather than place randomly hoping the space is free you should divide the space up into grid cells and pick one, place then mark off so it can't be used again. Link to comment Share on other sites More sharing options...
glass22 Posted December 28, 2013 Author Share Posted December 28, 2013 Ok thanks, for the second question is there anyway to do all sprites in one? like Game.Global.forEach ? Or do I have to call each group indv? Link to comment Share on other sites More sharing options...
glass22 Posted December 28, 2013 Author Share Posted December 28, 2013 One other quick question, is there a way to change the image of a sprite? or do I need to kill it and remake at same location with new image? Link to comment Share on other sites More sharing options...
evan312 Posted December 28, 2013 Share Posted December 28, 2013 One other quick question, is there a way to change the image of a sprite? or do I need to kill it and remake at same location with new image? you could change the animation frame i think. Link to comment Share on other sites More sharing options...
XekeDeath Posted December 28, 2013 Share Posted December 28, 2013 Or use the loadTexture function, if you are not using a spritesheet. Link to comment Share on other sites More sharing options...
glass22 Posted December 28, 2013 Author Share Posted December 28, 2013 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts