How do I set a random spawning between two x coordinates?

Get help using Construct 2

Post » Sun Dec 27, 2015 3:50 am

I am making a music bar, and I want to set notes to randomly span different positions on the bar, but I want the note to stay in the correct place. I have set the correct y position, but I want it to be able to spawn anywhere between the beginning of the bar and the end (on the x scale), but not anywhere else on the view-able screen. Any ideas? :?:
B
6
Posts: 10
Reputation: 285

Post » Sun Dec 27, 2015 5:18 am

Create object note on layer at x=random(music_bar.x + music_bar.x/2 , music_bar.x - music_bar.x/2), y=(the value that you have)
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Sun Dec 27, 2015 6:43 am

I have 7 notes, and I only want one to show up on the screen at a time. I think I can do that using a family, but it won't let me enter the formula. Also, how would I make a family - spawner that spawned the different notes at different y-coordinates? I think the formula would be a little different for that, right?
Last edited by wingzrooke on Sun Dec 27, 2015 6:57 am, edited 1 time in total.
B
6
Posts: 10
Reputation: 285

Post » Sun Dec 27, 2015 6:56 am

Families are only available in the personal or business licence and not in the free version Im afraid.

Make a variable that checks if the note is on screen, for example:
0 - for no, 1 for yes (or you can set up a boolean under object instance varaibles, in the left panel once you select a sprite)

Note_Spawned=0

If Note_Spawned=0 ---> spawn object note at x,y (as in the post above), set variable Note_Spawned=1

If note is not on screen ---> set Note_spawned=0
(this is to terminate the note, and once terminated allow another note to be spawned)
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Sun Dec 27, 2015 6:59 am

I do have the personal license, it just doesn't show up on Scirra because I bought it through Steam. I tried the formula, but no matter how I enter it it keeps telling me something is wrong. Mostly it doesn't like the "," in the middle of the x formula...

I tried it exactly as shown above.
B
6
Posts: 10
Reputation: 285


Return to How do I....?

Who is online

Users browsing this forum: tikuna, Yahoo [Bot] and 11 guests