center a group of sprites created on runtime by their origin

  • Hi community,

    How can i group a collection of sprites that are created on runtime and have them center on-screen as the combined group or with their combined origin point?

    Many thanks in advanced.

  • Animate

    you could create an invisible "guide" sprite with image points spaced out a little wider than the sprites and pin the sprites to it. if that guide sprite has its origin in the middle, then that would be easy to place in the middle of the screen. Moving that sprite would then move the whole group...

    otherwise you would have to manually, sum up the widths of the sprites, and add in the distance you want between them and calculate where to place each one.

  • Thanks

    I believe the second option is the way to go.

    Does anybody know the expression or the automated way through events that this can be done in runtime? Or an even better alternative, as i believe that there has to be a more simplified way to this?

  • for 1 to sprite.imagepointcount

    create object at sprite.imagepointX(loopindex)

    create object at sprite.imagepointY(loopindex)

    pin object to sprite.

    this will loop through all imagepoints on a sprite, and do whatever you want at each point. you probably want to pin it to the main sprite object

  • justifun, i tried your method but the group of created sprites all center on top of one another, not like a combined group that moves to the center at their center point of origin.

    Would you be able to to demonstrate to a brief .CAPX. or perhaps a simpler method using the sprite.witdth expression for the entire group if possible?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Example capx of the first idea.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)