User Tag List

Results 1 to 6 of 6

Thread: Summing the values of an array

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Dec 2008
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Summing the values of an array

    I have a situation in my game where it would be most convenient if I could sum up the values of a number array object. Is there any non-painful way to do this?

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does the Array have a fixed or maximum number of Rows/ Columns?
    What specific Rows/ Columns do you need to sum up?

  3. #3
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Dec 2008
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using KcArray.mfx - it's fixed at 9 by 10. I want to sum up the entire matrix.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS 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)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not familliar with the KcArray.

    You could use a Fast Loop to itterate through the Array.
    Fastloops can be abit slow however.
    If you just want a 1 time summary every now and then, like summin up scores or something, i guess Fast Loops would be ok.

    Alternatively, and to avoid Fast Loops entirely, you could make a long expression manually wich adds all the cells in the Array together.
    If i was confident in my design solution this is what i would choose.
    Beware though, the expression would be very long and im not sure if there is a limit to how long an expression can be in MMF2.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just use a Fast Loop, adding them manually would be way too much effort. You'll need an alterable value or Counter to store the sum of the values (let's call this "Sum"). Supposing your array is 9 cells wide and 10 cells in height:

    On Loop "GetSum":

    - Add ValueAtXY( "Array", LoopIndex("GetSum") Mod 9, LoopIndex("GetSum") / 10) to Sum

    At the end of the loop, Sum will contain the sum of the cells.

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by King_Cool View Post
    Not familliar with the KcArray.
    I'm not sure why he chose to post the filename instead of the extension name, but the default Array object by Clickteam is KcArray.mfx (many CT extensions start with Kc and the prefix is not allowed for 3rd party developers - I believe Kc is for Klik & Create)

Similar Threads

  1. Add values to Array without setting X and Y
    By Boba Fonts in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 13th March 2012, 12:58 AM
  2. Couples of random values in an Array
    By K1kk0z90 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 11th December 2011, 05:35 PM
  3. Array vs. Counter vs. Object values
    By alxmrg in forum Hardware Accelerated Runtime
    Replies: 7
    Last Post: 19th May 2010, 11:12 PM
  4. Array of displayable strings/values?
    By Farflame in forum Multimedia Fusion 2 - Technical Support
    Replies: 20
    Last Post: 8th June 2009, 07:11 PM
  5. Write and read 2 values at a time from array.
    By Popcorn in forum File Archive
    Replies: 0
    Last Post: 1st April 2008, 02:09 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
  •