User Tag List

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

Thread: Number of Active Objects with the same Alterable Value

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Mar 2010
    Location
    Slovenia
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Number of Active Objects with the same Alterable Value

    I have 100's of copies of active object named "ACTIVE01" on the screen.
    Those object carries a different values in "Alterable Value A" (for 1 to 10).
    I have a lot of calculations to do between cycles so I need the fastest way to get a number of objects that have the same value in "Alterable Value A"?

    so:
    how many "ACTIVE01" have "Alterable value A" = x

    Thank you in advance! :-)

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    The Select Object extension is the easiest and most efficient method, if it's compatible with whichever exporter(s) you are using.
    Failing that, use a ForEach loop (a fastloop would work too, but it would be inefficient).

    Another alternative is this:
    + Alt Val A of ACTIVE01 = X
    -> Create Token at 0,0 from ACTIVE01
    -> Set Counter to NoObjects("Token")
    -> Destroy Token

    That will create one Token for each ACTIVE01 with an Alt Val A of X, so you can then count how many were created, and then immediately destroy them all. It seems pretty inefficient to me, but it's been suggested before by someone (I forget who).

  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)
    another quite efficient method is this:

    Alt Val A of 'Active' = X
    +flag 0 is off
    +pick one 'Active' at random
    -> add 1 to counter
    -> set flag 0 ('active') on

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Yeah, if you want to use a fastloop, that would be the way to do it (obviously you wouldn't do that outside of a fastloop, or it would be way too slow - taking several seconds) - but it's still simpler and quite a bit more efficient to use the ForEach or Select Object extensions.

    eg.
    + Alt Val A of Active = X // Note that you only run 1 loop for each object that meets the condition (not 1 loop per object) and the loop itself doesn't have any conditions to test
    -> Set Counter to 0
    -> Start ForEach loop for Active

    + On ForEach loop for Active
    -> Add 1 to Counter

  5. #5
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Easiest method is ForEach loop and compare the two values. If equal, add 1 to some counter value

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    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)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a much better method: Still requires ForEach object, but you don't need to loop.
    Simply add the Actives to a group and then get the number of members in the group.
    You'll need to clear your group beforehand.

    Here's an example to show how the counting can all be on one line (requires ForEach object)
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Mar 2010
    Location
    Slovenia
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Guys, thank you very, very much! :-)
    I need to make some tests to see which way will be the best for my case. I will let you know!
    Thank you again!

  8. #8
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleXNA 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)
    gkinfinity's Avatar
    Join Date
    May 2011
    Location
    USA
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @AyreGuitar: Thanks for the example, but I'm not getting consistent results with it. Sometimes when you toggle an object's Alt Val A the count doesn't change properly.

  9. #9
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Hai!

    This may be better suited to what you were looking for.

    All of the counting in my example is done in one single frame loop.
    Attached files Attached files

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, the foreach object will do a loop taking only the actives with a certain condition true to them, which is very handy, so you dont actually need any further conditions or an actuall loop taking place at all. I revised the ProdigyX example to show you what i mean:

    https://dl.dropbox.com/u/14962632/Pu...ing%20rev2.mfa

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Max number of active objects.
    By Kalnar in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 19th January 2008, 07:20 PM
  2. [Request] Active Objects: Reset Alterable Values
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 4th January 2008, 08:06 AM
  3. Number of active objects
    By Phandmar in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 15th April 2007, 05:51 AM

Posting Permissions

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