A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Spacing by interval and slope

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834

    Spacing by interval and slope

    I'm working on this project: http://www.typhoonent.com/dragonrocketpanic.html The problem if you look at the example, is spacing the circles. I need to figure out how to space the evenly. Any good ideas on how to proceed would be very appreciated.

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    404
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    http://www.typhoonent.com/dragonfirepanic.html Yeah I've been doing some work on it. I got a partly working system down but if I have too many circles it messes up.
    .

  4. #4
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    What if you place all the circles in a grid formation, but afterwards apply a random x/y offset to each one. That way you could control more how evenly distributed they all are
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  5. #5
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    The thing is I would like to evenly space them out. Plus the spacing keeps changing. I guess that I just don't see what you are aiming at.
    .

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    your link is dead...did u sort the problem out?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  7. #7
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    lol sorry, I just did some moving around. I did find a solution, but it still has problems. I can't have it do too many and when it's returning it comes back a little crooked. the link is www.typhoonent.com/dfp/dragonfirepanic.html the code I'm using is this:
    code:
    var intervalx:Number = arm._x+dist*Math.sin(mAngle/180*Math.PI);
    var intervaly:Number = arm._y-dist*Math.cos(mAngle/180*Math.PI);
    var pointA:Array = new Array(hand._x, hand._y);
    for (i=0; i<Math.ceil(nCircles/2); i++) {
    if (i+1 != Math.ceil(nCircles/2)) {
    intervalx = (pointA[0]+intervalx)/2;
    intervaly = (pointA[1]+intervaly)/2;
    } else {
    intervalx = (intervalx-pointA[0])/2;
    intervaly = (intervaly-pointA[1])/2;
    }
    }
    for (i=0; i<nCircles*2-2; i++) {
    drawCircles((hand._x+intervalx/2)+intervalx*i,(hand._y+intervaly/2)+intervaly*i,i+1);
    }

    .

  8. #8
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Quote Originally Posted by swak
    The thing is I would like to evenly space them out. Plus the spacing keeps changing. I guess that I just don't see what you are aiming at.
    I mean, you can initially place all the circles in an even distance from eachother on the screen:


    Code:
    *  *  *  *  *  *
    *  *  *  *  *  *
    *  *  *  *  *  *
    *  *  *  *  *  *
    *  *  *  *  *  *
    *  *  *  *  *  *
    And then loop over each circle and move its x and y positions by a random amount (scaled by the randomness you want)

    so you'd end up with a formation similar to the grid, except they won't be aligned, and look more randomly positioned

    Edit: There's a great article about just this: spacing things out evenly, in Game Developer magazine from a few months ago... if you are subscribed
    Last edited by ozmic66; 08-30-2007 at 01:02 PM.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  9. #9
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I want them spaced evenly though.

    Thanks for your help everyone.
    .

  10. #10
    Senior Member
    Join Date
    May 2006
    Posts
    145
    there is something wrong...
    when your hand is pulling back, it is not straight, a bit to the left

    then just make a temporary invisible larger movie clip.
    when you regenerate your ball, put the larger MC at the same position (the center position)
    hit test it with other balls, if it hits, then erase it, move it, and just keep repeating until it found an empty space far enough from the rest of the ball. then remove the the test MC from the stage, to be used later with other new balls.

  11. #11
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    hmm I noticed that problem. The balls that keep randomly being placed are just for testing. Just to make sure we're all on the same page this is for the circles that are between the hand and the arm. I've been working on a map editor so this has taken a bit of the back stage for now but once I get the editor working then I'll get back on the game. If any of you are curious my map editor is here: www.typhoonent.com/dfp/mapeditor.html On a different note. In the map editor I have the comboBox component. The problem is when I try to swap depths like two times with it, the drop down animation stops working for no apparent reason.
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center