How do I spawn sprites in a circle formation?

Get help using Construct 2

Post » Mon Apr 04, 2016 8:48 pm

Hi guys

I was trying to crack this for a while. But my scirra skills are not there yet.
If i would like to spawn coin sprites in a circle formation, like say for every 30 degrees. Is there a smart way of doing that? I tried messing with set spawn locations but i feel there should be a better way of doing it.

Cheers
B
7
S
1
Posts: 12
Reputation: 799

Post » Mon Apr 04, 2016 8:59 pm

I'm pretty sure there is a plugin on the Scirra Store for this...
Download Pistons:

Image
B
20
S
5
G
8
Posts: 49
Reputation: 4,576

Post » Mon Apr 04, 2016 9:07 pm

try:
Image

360/30= 12 :D
Image
B
64
S
23
G
7
Posts: 1,482
Reputation: 10,825

Post » Mon Apr 04, 2016 9:20 pm

here is a solution without math

Image
In this case it's 45 degrees and I just made some additional image points to my sprite 1 object

Edit: Sprite1 could be an invisible helper and you set the image point wherever you like (like 12 image points around the Sprite1)

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Mon Apr 04, 2016 9:46 pm

FYI:

Spawn point - (x,y)
where:
x = CenterX + RADIUS * cos(YourAngle)
y = CenterY + RADIUS * sin(YourAngle)

CenterX, CenterY - center of your circle
RADIUS - circle radius
YourAngle - angle you want from 0 to 359

I think korbaach's solution is better (imo)
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Apr 04, 2016 9:48 pm

Amazing guys. :) Always new ways of doing stuff pop up.
Thanks a million.

Cheers
B
7
S
1
Posts: 12
Reputation: 799

Post » Mon Apr 04, 2016 10:48 pm

fm4fanAT wrote:here is a solution without math

Image
In this case it's 45 degrees and I just made some additional image points to my sprite 1 object

Edit: Sprite1 could be an invisible helper and you set the image point wherever you like (like 12 image points around the Sprite1)


What exactly is the 'local number = image point 1' and how is it being used? I'm not recalling how to create such at thing.
B
197
S
110
G
7
Posts: 134
Reputation: 19,564

Post » Mon Apr 04, 2016 10:57 pm

it is a local variable (type number, start value = 1) for the repeat loop.
each loop the local variable is increased by 1 and create a sprite "Sprite2" at next image point of sprite "Sprite".
Local variables are variables placed nested under other events, or inside a group(right click on event to create add a local variable)
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Apr 04, 2016 11:03 pm

MadSpy wrote:it is a local variable (type number, start value = 1) for the repeat loop.
each loop the local variable is increased by 1 and create a sprite "Sprite2" at next image point of sprite "Sprite".
Local variables are variables placed nested under other events, or inside a group(right click on event to create add a local variable)



but isn't that meaning you also have image points all around the "Sprite" object? cause without them you wouldn't have a 360 degrees pattern



korbaach wrote:try:
Image

360/30= 12 :D


oh now i see the use of Sin and Cos nice thanks man :D
B
70
S
20
G
67
Posts: 1,316
Reputation: 42,305

Post » Mon Apr 04, 2016 11:47 pm

should be only one additional image point,you can rotate spriteSpawner
Image
Image
Image
Image
B
64
S
23
G
7
Posts: 1,482
Reputation: 10,825

Next

Return to How do I....?

Who is online

Users browsing this forum: mikehive, plinkie, Yahoo [Bot] and 10 guests