An array of graphical objects?

For questions about using Classic.

Post » Sun Feb 22, 2009 11:31 pm

I read somewhere within the forums that one could make an array of objects, for example sprites.

I cannot possibly figure out how this is done. Can someone elaborate? I saw a spawn action typed somewhere, but couldn't get to it myself. Just now figured instancing with ctrl-dragging.
I'd like to get an array of 1px-high tiledbackground instances, vertically arranged.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Mon Feb 23, 2009 12:51 am

Why not just stretch the tiledbackground?

But if you're doing something different, you can do an array paste for objects in the layout editor. Just copy an object, right-click the layout, and then click "Array paste". You can set all the options like X and Y spacing, angle, size, and the amount of objects in the window that pops up.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Wed Feb 25, 2009 4:21 am

Is there any way to access the pasted objects by index?
Array paste appears to just help aligning multiple instances, and the Array object seems to be a standard data array.

Which is the best way to access an object by an index? I want to loop on them and execute actions on each (change position, stretch, etc) based on the index, but I don't quite understand the loop action.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Feb 25, 2009 4:32 am

Ah, I see. I can't really express how to do it in words, but here's a quick CAP I whipped up showing how to mess around with sprites based on their index: Sprite array thingy.

Not the best demonstration, but I hope you get the idea. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Wed Feb 25, 2009 7:19 pm

O_O bizarre, when I tried to open it Construct complains that "the file was saved in a newer version of Construct", yet update reveals I'm using the latest (0.98.7)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Feb 25, 2009 7:23 pm

There is a new version out, but we don't put it on the autoupdate for a few days incase of serious problems.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sat Feb 28, 2009 6:28 am

that worked.

The cap illustrates exactly what I wanted to know, thanks.
For others reading this thread:

Set a private variable Index in the object, place one copy in the layout.
events:
on layout start destroy the object, then loop and spawn objects setting the index variable to the current index, increment index manually inside the loop.
always loop foreach object, do whatever with the index.

cool. Will play extensively with this. Oh yes.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests