How do I Randomize Sprite Spawns

Get help using Construct 2

Post » Wed Oct 15, 2014 6:20 pm

OK, so right now I'm working a zombie themed top-down shooter. When enemies die they spray blood and then they spawn a blood sprite on the ground. What I want to do is to randomize the sprites because I have two sprites for blood. This is my first project so detailed instructions would be nice if this is at all possible.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 2
Reputation: 179

Post » Wed Oct 15, 2014 7:24 pm

Hi, you can do this:
Have just 1 object for blood, but the 2 differentes sprites as frames in the animation... set the animation speed to 0.

then create that object (blood) and "set animtion frame" to choose(0,1) that will choose either frame 0 (blood 1) or frame 1 (blood 2) and that's all.


one more thing, it's easier when uploading files to save as capx.

good luck
Image
B
58
S
13
G
6
Posts: 271
Reputation: 12,128

Post » Mon Nov 03, 2014 2:21 pm

ok so it just plays through the frames, how do i get it to freeze?
B
3
Posts: 2
Reputation: 179

Post » Wed Nov 05, 2014 5:44 am

the first line, set animation speed to 0
Image
B
58
S
13
G
6
Posts: 271
Reputation: 12,128

Post » Wed Nov 05, 2014 6:46 am

You choose the frame you want displayed via actions after you have set animation speed to 0.
If you want it to be random you will need to put an instance variable in the object called something like splatter then On created event have it do a choose(0,1) action and set the zombies splatter variable at creation to 0 or 1. Now in the zombie die event add two sub-events with conditions of splatter = 0 then action set frame 0 and condition event splatter = 1 set frame 1 actions.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Wed Nov 05, 2014 9:48 am

chrisinfinger wrote:You choose the frame you want displayed via actions after you have set animation speed to 0.
If you want it to be random you will need to put an instance variable in the object called something like splatter then On created event have it do a choose(0,1) action and set the zombies splatter variable at creation to 0 or 1. Now in the zombie die event add two sub-events with conditions of splatter = 0 then action set frame 0 and condition event splatter = 1 set frame 1 actions.


That's a lot of events instead of

Splatter on created
- splatter set frame to : choose(0,1)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Nov 05, 2014 11:28 pm

That's a lot of events instead of

Splatter on created
- splatter set frame to : choose(0,1)


I knew there had to be a more efficient way to use choose. :)
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 30 guests