Help with spawning a random enemy

For questions about using Classic.

Post » Fri Jul 16, 2010 12:56 pm

Hi, i am training construct, and its quite awesome, but i have a problem, i wanted to create a button that when we clicked, it starts a timer and at each second it has a change of spawning an enemy, i know it has something to do with time delta, and some random variable, that if the random variable equal to 1 for example, it turns the enemy visible or spawn an object, but im trying but i cant make it works, can someone help me plz?

Thank you
B
3
G
2
Posts: 11
Reputation: 697

Post » Fri Jul 16, 2010 1:05 pm

Try a group.

>On object clicked
->system set group "spawn" enabled

-group "spawn"
> every xxxxx miliseconds
-> system create object enemy at random() x,y
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Fri Jul 16, 2010 2:14 pm

newts would work
also just as easy would be a global variable ('spawningon')

if ('spawningon') = 1
system create enemy

also if you want the enemy to be random, put all the enemies in a family
let's say you put them in a family called enemies

if you create object "enemies"
it will choose something from the family at random to create
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Fri Jul 16, 2010 3:33 pm

Just one question, where i create a group?

Thank you again for the help
B
3
G
2
Posts: 11
Reputation: 697

Post » Fri Jul 16, 2010 3:49 pm

right click where you would create events
create group instead

honestly if the enemy spawning thing is the only thing the group will do, I see no reason to use a group instead of a pv, groups are more suited to large sequences of events, not just one simple action

just use a global or private variable, I would suggest
but do go ahead and test out groups anyway so you can see what they are
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Fri Jul 16, 2010 4:21 pm

Im sorry but cant do it, cant find the IF statement, only find Else OR While, im new to this and im sorry but u both talk as if i know about construct sorry :( but thank you anyways.
B
3
G
2
Posts: 11
Reputation: 697

Post » Fri Jul 16, 2010 5:10 pm

Try the ghost shooter tutorial linked on the main scirra site
To learn the basics
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Sat Jul 17, 2010 2:19 am

The IF statement in construct is actually called a "Compare" your looking for System -> Compare Global Variable
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Sat Jul 17, 2010 7:56 am

I already did the ghost tutorial about 1 week ago and did other 2 tutorials, but finally i could do it :D thank you all for the help.
B
3
G
2
Posts: 11
Reputation: 697


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests