User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: perceived center

  1. #1
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    perceived center

    I want to make an object move toward the center of all the other objects of the same type (instances). I know how to get the average position of all the objects (loop, add up all positions and then divide by NObjects) but how would I go about averaging the positions of all instances bar one? Also I want to do this for all instances so each one moves toward the average center of all the others.

    Basically:

    for each object:
    if object != another instance of itself:
    --> add x/ypos to SumPos

    AvgPos = SumPos / (NObjects - 1)


    I tried -

    On loop:
    + id <> loopindex
    --> add xpos to xsum
    --> add ypos to ysum


    and with ForEach -

    fixedObj <> LoopFV
    --> do stuff

    But with this it seems to think that the center is an average between the left of the frame and the objects!

    Also tried nested loops and all that but still no luck. Hope this makes sense, really would appreciate the help.

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    You're more or less there - not sure what the problems is?

    http://skydrive.live.com/redir?resid...094271BBDA!528

    + Always
    -> Set SumX to 0
    -> Set SumY to 0
    -> ForEach: Start Foreach loop "GetPos" for "Object"

    + ForEach: On ForEach loop "GetPos" for "Object"
    -> Add X("Object") to SumX
    -> Add Y("Object") to SumY

    + Always
    -> Object: Set TargetX to (SumX-X( "Object" ))/(NObjects( "Object" )-1)
    -> Object: Set TargetY to (SumY-Y( "Object" ))/(NObjects( "Object" )-1)

  3. #3
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Can I just confirm that this figures out to the same as:

    Object is not other objects
    --> Add OTHER Objects to the count

    or :

    perceived center of other objects) -
    pcQ = (b1.position + b2.position + ... + bQ-1.position +
    bQ+1.position + ... + bN.position) / (N-1)

    where (1 <= Q <= N)

    rather than :

    center -
    c = (b1.position + b2.position + ... + bN.position) / N

    Is this what's basically happening?

    Cheers

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Note this part:
    -> Object: Set TargetX to (SumX-X( "Object" ))/(NObjects( "Object" )-1)
    -> Object: Set TargetY to (SumY-Y( "Object" ))/(NObjects( "Object" )-1)

    We're adding up the X and Y coordinates of every instance, but then each instance subtracts its own X and Y coordinates from those totals, and we divide by 1 less than the total number of objects - so yes, each instance is looking only at the others, and not itself.

  5. #5
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Cool, I think I realised that but I wanted to be sure.

    Can this be generalised to, say, finding distance? If object is not other objects (but still an instance), find the distance to the closest? I'm still having trouble with getting distances to other instances.

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    No, to find the distance to the closest instance you really some kind of nested loop, like in the examples I gave you previously.

  7. #7
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Ok cool, thanks Muddy you're a legend.

  8. #8
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Didn't want to start a new thread but just on the distance thing - why does this example not work with ForEach (I did your nested loop thing, but I read somewhere that it doesn't work for the same object)? Also why does the fastloop one only select one of the objects when it should select two that are close to each other?

    postest.mfa

    Thanks!

  9. #9
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Re: The fastloop version:
    I don't know what you're expecting to happen, but this is what's actually going to happen:
    It picks the newest object, and then highlights* all objects within 50 pixels of it.
    It then moves on to the next newest object, de-highlights it, and then highlights all objects within 50 pixels of it.
    It continues like this until it has highlighted all objects within 50 pixels of the oldest object - but some other objects will also have remained highlighted if they are within 50 pixels of an object older than themselves.
    * By "highlighted", I mean that its animation frame is set to 1.


    Re: The ForEach version:
    You run a ForEach loop called "pos2", which will deselect* all except one object at a time. However, you also compare the object's fixed value against the LoopFV of a different ForEach loop called "pos", which will deselect all other objects except for the one that matches.
    What that means is that the only time any objects at all will be selected, is when the same single object is selected by both ForEach loops, and in that situation nothing will happen because the X and Y positions will equal X1 and Y1.
    * By "selected", I mean that it's included in the object scope - ie. actions will apply to it (see: http://www.create-games.com/article.asp?id=1942 ).

  10. #10
    Clicker Fusion 2.5iOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Fastloop: this is well and good, I'm testing the distance of each active against all other actives and highlighting any within a 50px radius. But I thought it would also select the one doing the testing, seeing as it is also being tested by another one? Is this not like running a nested for loop that compares each object in a list to each object in another list?

    ForEach: ah, yep, but I don't know any way of nesting loops for the same object with ForEach, and I read here somewhere that perhaps it's not possible, but the reasons were unclear.


    EDIT: Got the fastloop version to work setting to frame 0 before running the loop, but in a separate event before it. Seems you have to set initial conditions separately from running the fastloop. So... why can't foreach do this?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Notification Center
    By Yos in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 2nd May 2012, 04:38 PM
  2. Game Center
    By Kisguri in forum iOS Export Module Version 2.0
    Replies: 116
    Last Post: 23rd January 2012, 01:13 PM
  3. Game center!
    By SoftWarewolf in forum iOS Export Module Version 2.0
    Replies: 7
    Last Post: 30th July 2011, 10:27 PM
  4. Center display.....
    By videogiochi in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 26th July 2010, 05:17 PM
  5. Media Center
    By Rene in forum Extension Development
    Replies: 0
    Last Post: 19th November 2009, 04:20 PM

Posting Permissions

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