how to stop Spawn same frame on screen

Get help using Construct 2

Post » Thu Jun 15, 2017 4:58 pm

I have sprite contain 7 Animation with bullet behavior
outside of layout their are spawner who spawn that object and shows animation randomly
But I don't want to repeat same animation while another is already running on screen

Please help how to do that ??
Image
B
68
S
40
G
48
Posts: 680
Reputation: 34,066

Post » Thu Jun 15, 2017 5:22 pm

You want all of the bullets instances to have the same random animation on spawn? Or the ones that spawn they keep repeating their old animation so it looks weird?
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Thu Jun 15, 2017 5:28 pm

i want to spawn all animation randomly
but do not spawn that animation which is currently on screen
but when animation goes out of screen that it can be spawn
Image
B
68
S
40
G
48
Posts: 680
Reputation: 34,066

Post » Thu Jun 15, 2017 5:40 pm

Okay that can get complicated a bit. You will have to keep track of which animation is already in use, if you use a random function to call the animation, you can keep an array with all values 0, lets say when animation 5 is called, you make the 5th cell of the array to 1 which means that animation is in use.

You will probably have to modify the random function a bit, add a global variable called animations_In_Use set it to 0 on start, then system -> set global variable -> animations_in_use = random_number_function. As a sub event array compare at x -> Array[animations_In_use] == 1, if true recall the event again to generate another random number, if its false spawn the animation.

Next you will need to keep track if bullet with animation is out of screen, You can assign the animation number of the array to local variable, and add an event like bullet is visible on screen( inverted) bullet id = 5, if its true reset the cell 5 to 0.

Its pretty complicated to pull of, i hope i gaved you an idea on how to make it.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Fri Jun 16, 2017 8:50 pm

No Array.
And no Destroy2Recreate events.
Is bad 4 performance and often breaks logic due the Newly Created Object Issue.

https://www.dropbox.com/s/cdr8766ssjfn0 ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jun 17, 2017 1:39 am

99Instances2Go wrote:No Array.
And no Destroy2Recreate events.
Is bad 4 performance and often breaks logic due the Newly Created Object Issue.

https://www.dropbox.com/s/cdr8766ssjfn0 ... .capx?dl=0


This idea is great
Thank you so much
Image
B
68
S
40
G
48
Posts: 680
Reputation: 34,066

Post » Sat Jun 17, 2017 10:34 am

This is done in the classic paradigm. Create and then recreate.

https://www.dropbox.com/s/u0d7el8rokd0v ... .capx?dl=0

Driven by an array.
Lately i started 2 dislike this.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests