Spawning a Family object

For questions about using Classic.

Post » Sat Jan 03, 2009 2:57 am

Lets say I wanted to spawn a bunch of random Enemies from one sprite. If I put all of the Enemy sprites in the Enemies Family and then chose to spawn an Enemy Family every 1000 ms it is suppose to pick one of the enemies and create one every second right? well thats what I wish would happen for me, instead, nothing appears. If you have NO idea of what Im trying to do heres my .cap example =>[url:3w20epy6]http://highimpact.sitesled.com/randomspawn.cap[/url:3w20epy6]
B
2
S
1
G
4
Posts: 239
Reputation: 1,778

Post » Sat Jan 03, 2009 3:59 am

The spawn/create actions weren't designed to create families. I didn't think they even showed families as a type you can pick, but I guess it does. I'll add the functionality you want for the next build then. If you have A, B and C in family F, and you spawn F, you get a random A, B or C.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sat Jan 03, 2009 4:23 am

Woot! thanks ashley your the best!
B
2
S
1
G
4
Posts: 239
Reputation: 1,778

Post » Sat Jan 03, 2009 10:26 am

Yes, please that would be a great addition.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sun Jan 04, 2009 8:15 am

Anybody else notice that we get treated like royalty around here?
Good work dev team!
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Sun Jan 04, 2009 1:24 pm

It was two lines in the source code, heh. All I had to type was this:

[code:8mcyr0hx] // Family passed: pick a random sub-type
if (pType->IsFamily())
pType = pType->teams[(unsigned int)(Random() * (double)pType->teams.size())];[/code:8mcyr0hx]

No problem to add little things like this :P
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Mon Jan 05, 2009 7:20 am

wow nice! Dang I wish I could program anything, I cant get past hello world :( code looks exactly like the example but doesnt have the same result
B
2
S
1
G
4
Posts: 239
Reputation: 1,778


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests