How do I spawn another object randomly on the sprite?

Get help using Construct 2

Post » Sun Jun 26, 2016 10:20 am

You beat the boss, and now it's about to explode in classic Metal Slug fashion. How do I spawn these explosions on random points of the sprite?

I understand I can use the (ciel ----) thing coupled with actual Image Points, but I was wondering if it's possible to just spawn randomly on the sprite without the need of creating tons of image points.
B
24
S
10
G
1
Posts: 153
Reputation: 2,660

Post » Sun Jun 26, 2016 10:49 am

You could use the Bounding Box as border.
https://drive.google.com/file/d/0B5FlDY ... sp=sharing
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Sun Jun 26, 2016 10:53 am

Asmodean wrote:You could use the Bounding Box as border.
https://drive.google.com/file/d/0B5FlDY ... sp=sharing


I'm not sure I understand, I was wondering if it's possible to spawn another object at a random point on a sprite without the need for Image Points.
B
24
S
10
G
1
Posts: 153
Reputation: 2,660

Post » Sun Jun 26, 2016 11:36 am

every 0.5 seconds
create sprite at
x: random(bossSprite.BboxLeft,bossSprite.BboxRight)
y: random(bossSprite.BboxTop,bossSprite.BboxBottom)

something like that should work.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Sun Jun 26, 2016 11:38 am

Sweet, thanks for the advice! I'll give it a shot.

May I ask if you can further explain what exactly it does, for newbies? You won't learn anything if you're just given the straight answer ^-^
B
24
S
10
G
1
Posts: 153
Reputation: 2,660

Post » Sun Jun 26, 2016 11:50 am

Bbox is the x and y values of the outer edges of the sprite.

Keep in mind though that if your sprite is rotated the Bbox will still be at the Outer edge surrounding the sprite.
If you have a square and and rotate it 45 degrees to something like this shape.. <> then the Bbox will still be a standing square at the edges of the rotated sprite. like this. [<>] hope that helps.
Last edited by tunepunk on Sun Jun 26, 2016 11:51 am, edited 1 time in total.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Sun Jun 26, 2016 11:51 am

Worked perfectly, thank you very much.

Everything is pretty self-explanatory minus the BboxLeft/Right/Top/Bottom thing. What do these refer to? Seems handy.

EDIT: I see you've responded, thank you very much! Very good explanation, thank you :)
B
24
S
10
G
1
Posts: 153
Reputation: 2,660


Return to How do I....?

Who is online

Users browsing this forum: alextro and 1 guest