create sprites randomly on 9 points

Get help using Construct 2

Post » Sat May 19, 2012 10:30 am

hey you out there,

i whonder how to do the following:

within a certain time, i.e. 30 seconds, i wanna create a certain number of sprites (lets say 20) spread on 9 points.
Imagine: 3 columns & 3 rows, so there are 9 objects in the grid .

1. the sprites are to be created randomly on these 9 points
2. the sprites shouldnt appear in a foreseeable intervall, so i guess it must be something like:
     "create the second item after the first was created (and so on), within a time of (i.e.)2 seconds",
     but it should be a random time-value, otherwise it`s boring.

3. it`s not allowed to create more than 1 object at the same time (this would be unfair towards the player).
4. it`s not allowed to create more than 1 object at the same time at the same position.

My idea was to store 9 x&y coordinates with the sprites within an array.
But as i read it`s not possible to store sprites in an array,right?

So, i guess i have to store the 9 x/y values and connect them/ make a bridge to the sprite-instances?!
This is a crucial point for me right now.(just one of plenty )

I think (maybe to simple):
- i create an array with 9 values
- each array-value [from 0-8] has specific x & y values-
-choose randomly array-value


...but hell...how do i do this ?

Thanks for reading, suggestions, hints.... dformer2012-05-19 10:32:35
B
17
S
3
G
5
Posts: 71
Reputation: 4,401

Post » Sat May 19, 2012 10:57 am

it can be as easy as this
random9sprites.capx
Last edited by Yann on Sun Sep 14, 2014 8:30 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat May 19, 2012 11:12 am

pffff....now this is amazing!
but where are the grfx? sprite is set visible but i dont see any grafx???
a lot to learn i have, i guess

thnx Yann, this is great!

though i dont understand right now, whats happening here...

have a nice weekend!!dformer2012-05-19 11:15:08
B
17
S
3
G
5
Posts: 71
Reputation: 4,401

Post » Sat May 19, 2012 12:21 pm

the first animation frame is just empty, and the nine sprites are already created and positionned (snap feature helps for that)
Every 'next' seconds I just set the current sprite to frame 0 (empty) and randomly pick one sprite amongst the eight other sprites and set its animation frame to a random integer between 1 and 20.Yann2012-05-20 04:04:37
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat May 19, 2012 12:21 pm

[QUOTE=Yann] the first animation frame is just empty, and the nine sprites are already created and positionned (snap feature helps for that)
Every 'next' seconds I just set the current sprite to frame 0 (empty) and randomly pick one sprite amongst the eight other sprites and set its animation frame to a random integer between 1 and 20.[/QUOTE]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat May 19, 2012 7:36 pm

Ok,now i understand. This is clever.
thnx a lot for your explanation
B
17
S
3
G
5
Posts: 71
Reputation: 4,401


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests