Jump to content

callAll sprite position?


proyb2
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...