proyb2 Posted September 5, 2015 Share Posted September 5, 2015 How do I move bmd to new xy position using call all after it has added to game?game.add.sprite(i*20,0,bmd) Link to comment Share on other sites More sharing options...
Tom Atom Posted September 5, 2015 Share Posted September 5, 2015 I think, that you have to make such calls (callAll / setAll / ...) on parent group - then your requested operation will be applied to all children in that group. If you want to move your bmd, but keep sprite position, then you are looking for sprite property "anchor". Now bmd is displayed with its top left corner at sprite position (anchor = 0,0). If you change anchor to 1,1, it will be displayed with its bottom right corner at that point. Link to comment Share on other sites More sharing options...
kalevski Posted September 5, 2015 Share Posted September 5, 2015 If I understand you,you have for loop and you want all added sprites change with one line of code ?Slution:var group = game.add.group(); // GROUP OF ELEMENTSvar arrayOfElements = []; // ARRAY OF ADDED OBJECTS FOR CHANGING PROEPRTIES OF EACH OBJECTvar numOfElements = 10; // FOR EXAMPLEfor (var i=0; i<numOflElements; i++) { arrayOfElements[i] = group.create(i*20, 0, bmd); // HERE ADD OTHER OBJECT PROEPRTIES LIKE arrayOfElements[i].anchor.set(.5);}// AND ANYWHERE IN GAME YOU CAN CHANGE POSITION OF GROUPgroup.position = new Phaser.Point(45, 130); // x+45 & y+130 TO ALL ELEMENTS Link to comment Share on other sites More sharing options...
Recommended Posts