How do I spawn the same object in different places?

Get help using Construct 2

Post » Mon Apr 07, 2014 8:23 pm

Hi guys, I have one sprite that has a bullet behavior, and 2 another sprites with no behavior, its in these sprites where the bullet sprite must spawn, but the 'choosen' spawner sprite must be random. I dont know how to do that in the C2.
Could someone give a help? :roll:
In pseudo language, it would be something like this.

Code: Select all
Every random (1, 2) seconds do{
          Choose randomly 'Sprite A' or 'Sprite B';         
          Spawn 'Bullet Sprite' in the sprite choosen;
}
w.dropbox.com/s/dptx0tup1mek1qc/spawn2places.capx
B
3
Posts: 9
Reputation: 218

Post » Mon Apr 07, 2014 10:48 pm

"System --> pick random instance" could do that for you. Then on the action spawn the bullet.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Apr 08, 2014 9:21 pm

cvp wrote:"System --> pick random instance" could do that for you. Then on the action spawn the bullet.



It worked, thx for the help!
B
3
Posts: 9
Reputation: 218

Post » Tue Apr 08, 2014 9:38 pm

Now I have another question, I dont know if post here or if should create another topic.

Can I change the bullet movement angle, depending on the instance where the bullet was spawned?

This is my example now:

www. dropbox.com/s/dptx0tup1mek1qc/spawn2places.capx
Last edited by milk on Wed Apr 16, 2014 4:34 pm, edited 1 time in total.
B
3
Posts: 9
Reputation: 218

Post » Sat Apr 12, 2014 9:56 pm

Sure. You could create an instance variable and then set the angle to what you want depending on which of the instance you picked.
Use System --> compare two values after you have picked the random spawner instance.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Mon Apr 14, 2014 9:13 pm

cvp wrote:Sure. You could create an instance variable and then set the angle to what you want depending on which of the instance you picked.
Use System --> compare two values after you have picked the random spawner instance.



thx for the reply, but I didn't get, Should I create an instance variable for the Spawner sprite or to the Bullet Sprite?
B
3
Posts: 9
Reputation: 218

Post » Tue Apr 15, 2014 5:24 pm

If you want the spawner to spawn bullets in a curtain angle you should keep that angle on a instance variable on the spawner sprite.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Apr 16, 2014 2:50 pm

cvp wrote:If you want the spawner to spawn bullets in a curtain angle you should keep that angle on a instance variable on the spawner sprite.


Ok, I did that, but I'm still missing something, because it's only changing the angle of motion of the bullets that had already created, I want the inverse situation :p

take a look:

www . dropbox. com/s/dptx0tup1mek1qc/spawn2places.capx
B
3
Posts: 9
Reputation: 218


Return to How do I....?

Who is online

Users browsing this forum: matriax and 27 guests