Generate objects in shapes

Get help using Construct 2

Post » Thu Aug 22, 2013 3:09 pm

Hi,

I was wondering if anyone here have any examples or samples on how to create objects and have them appear in certain shapes.

Like for an example, a bunch of coins appearing in the shape of squares or pyramids.



I tried playing around with 2 For loops but results were disastrous.

Any help is very much appreciated. Thank you.
B
24
S
10
G
4
Posts: 39
Reputation: 4,179

Post » Thu Aug 22, 2013 3:41 pm

An array is what you are after! Are you comfortable with arrays? If not, you should read the tutorial 'arrays for beginners'.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Thu Aug 22, 2013 4:24 pm

I just took a quick look at the Arrays for Beginners and I think I get the idea.

Will give it a try later on. Thanks!
B
24
S
10
G
4
Posts: 39
Reputation: 4,179

Post » Sun Aug 25, 2013 2:28 am

I'm still having trouble with 2D array, even after following the example from the 'Arrays for Beginners'.

Does anyone have any other examples I can follow?
B
24
S
10
G
4
Posts: 39
Reputation: 4,179

Post » Sun Aug 25, 2013 3:16 am

No need to use an array just use two for loops. In fact the array wouldn't help in the case of the triangle.

For a 3x3 square whose top left is at x,y do this:

Global number x=100
Global number y=30

Start of layout
For "row" from 0 to 2
For "col" from 0 to 2
--- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

And for a triangle do this:

Start of layout
For "row" from 0 to 2
For "col" from 0 to loopindex("row")
--- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Sun Aug 25, 2013 4:46 am

[QUOTE=R0J0hound] No need to use an array just use two for loops. In fact the array wouldn't help in the case of the triangle.

For a 3x3 square whose top left is at x,y do this:

Global number x=100
Global number y=30

Start of layout
For "row" from 0 to 2
For "col" from 0 to 2
--- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y

And for a triangle do this:

Start of layout
For "row" from 0 to 2
For "col" from 0 to loopindex("row")
--- create sprite at 32*loopindex("col")+x, 32*loopindex("row")+y[/QUOTE]

Thanks! Will try it out.
B
24
S
10
G
4
Posts: 39
Reputation: 4,179


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 60 guests