How do I spawn sprites in a circle formation?

  • 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

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

  • try:

    360/30= 12

  • here is a solution without math

    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)

  • 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)

  • Amazing guys. Always new ways of doing stuff pop up.

    Thanks a million.

    Cheers

  • here is a solution without math

    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.

  • 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)

  • 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

    try:

    360/30= 12

    oh now i see the use of Sin and Cos nice thanks man

  • should be only one additional image point,you can rotate spriteSpawner

  • Brilliant. Thanks again guys.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • should be only one additional image point,you can rotate spriteSpawner

    Holy crap! That looks like a genius idea! I hope to remember to try that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)