How do I spawn objects in a grid?

Get help using Construct 2

Post » Wed Nov 05, 2014 2:59 am

I want spawn coin in a grid like Jetpack Joyride. Somebody help me?
B
8
S
1
Posts: 36
Reputation: 526

Post » Wed Nov 05, 2014 5:23 am

you can make a pivot as the center of your coin pattern.
then create object at
X = Pivot.X+32
Y = Pivot.Y+64

and so on.
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 292
Reputation: 6,678

Post » Wed Nov 05, 2014 6:53 am

can you make a example? please :D
B
8
S
1
Posts: 36
Reputation: 526

Post » Wed Nov 05, 2014 11:00 am

Yes, that would be great!
maybe for something like this...... :D :D :D
You do not have the required permissions to view the files attached to this post.
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Wed Nov 05, 2014 10:20 pm

While I would say an array is the easiest way I have thrown this together showing how you could do it with a string of 1's & 0'S.

HTML5 Demo

Press "Space" to make coins appear best wait until the last coins have gone off the screen before pressing "space" again.

jetpackjoyride.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Wed Nov 05, 2014 10:43 pm

Well done Minor ! :)

I did not expect someone to make an example...without using arrays :D
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Nov 06, 2014 12:02 am

korbaach wrote:Well done Minor ! :)

I did not expect someone to make an example...without using arrays :D


Why thank you.

Arrays would be much easier. Some people have trouble with them, although string manipulation is much more of a pain to work with.

I carried on playing and created a "Text to Coin" converter thingy.

Image

Need a better font and could also make it so I can save the coin pattern/text as JSON to load into an array.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Nov 06, 2014 2:07 am

Nice, thank you
B
8
S
1
Posts: 36
Reputation: 526

Post » Thu Nov 06, 2014 6:57 am

why you need to compare mid(pattern, loopindex("x"), 1) with "1" ?
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 292
Reputation: 6,678

Post » Thu Nov 06, 2014 7:36 pm

puntodamar wrote:why you need to compare mid(pattern, loopindex("x"), 1) with "1" ?


To find out if I need to create a coin or not. A 0 in the string is air/nothing while a 1 is a coin.

If you are asking why I'm checking for "1" rather than 1 then that's because the information in the "pattern" variable is stored as a "string/text" and not an integer/number. So if you checked for 1 it would never be true.

You could of course change it to int(mid(pattern, loopindex("x"), 1)) with 1 and covert the string to an integer.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests