center a group of sprites created on runtime by their origin

Get help using Construct 2

Post » Thu Aug 20, 2015 7:47 pm

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.
B
107
S
20
G
8
Posts: 155
Reputation: 11,741

Post » Fri Aug 21, 2015 2:43 am

@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.
B
98
S
35
G
20
Posts: 438
Reputation: 17,875

Post » Mon Aug 24, 2015 5:07 pm

Thanks @AllanR.

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?
B
107
S
20
G
8
Posts: 155
Reputation: 11,741

Post » Mon Aug 24, 2015 6:16 pm

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
B
88
S
44
G
16
Posts: 1,009
Reputation: 17,971

Post » Mon Aug 31, 2015 11:21 pm

@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?
B
107
S
20
G
8
Posts: 155
Reputation: 11,741

Post » Tue Sep 01, 2015 9:16 am

Example capx of the first idea.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,312
Reputation: 71,092


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 26 guests