User Tag List

Results 1 to 5 of 5

Thread: Array Problem

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jul 2006
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Array Problem

    When I do the following:
    Add an array and a counter to the frame.

    In the events menu add the following events and actions:
    Start of Frame - Set x index of array to 1
    When pressing Space (keyboard) - Add 1 to x index of array
    Always - Set counter to x index of array

    When I run the program it starts with the counter equal to 10 (it should start with the counter equal to 1) and no matter how many times I press the space key the counter does not change. I did make sure the type of array was "number."

    Am I missing something?

    Jason

  2. #2
    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)

    Re: Array Problem

    It works normally for me. You should probably check your code.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Array Problem

    The "index" property of an array is simply a pointer to where in the array it will retrieve data from using the "get value at current position" function. The index is not part of the array storage itself, and is limited by the size of any array- a size 10 array cannot have an index point beyond 10 (because logically this would cause an out-of-bounds error)


    I believe you are trying to use the array object in the wrong way. If you want to store data in it, you'll want to use the functions:


    "Write Value to X"
    and
    "Read Value from X"


    an example of a 1x1x1 array that stores just a single variable like a counter would run like this:



    Start of Frame - Write Value (1) to (X = 1)
    When pressing Space - Write Value ((Read Value at (X = 1)) + 1) to (X = 1)
    Always - Set counter to (Read Value at (X = 1))



    Think of an Array as a line (1 dimensional), square (2 dimensional) or cube (3 dimensional). Lets use a square for an example. Lets say we have a 10x10x1 array- this is the same as a 10x10 square. Each tile on that 10x10 square can hold a variable, for 100 tiles total. There can be 100 different numbers written into it, 1 in each slot.

    The index is simply a value for 1 to 10 for X, and 1 to 10 for Y, that points to one of these tiles when combined. So at index X=5, Y=5, you might retrieve whatever value was written there.


    In general you don't need to use the indexes at all- just directly retrieve and write variables from the positions in the expression editor. Using the indexes is just there to make some things easier to write, like if you were trying to access the same position over and over- you could set the indexes, then just read/write from the currently active index.

    For example:


    Start of Frame - Set X index of array to (1)
    Start of Frame - Write value to current position (1)

    When Pressing Space - Write value to current position ((Read Value from current position) + 1)

    Always - Set counter to (Read value from current position)

  4. #4
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export Module
    Chaos's Avatar
    Join Date
    Aug 2006
    Location
    Burnsville, MN, USA
    Posts
    806
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Array Problem

    I have an array example on my website also that covers this if you need a visual aid.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jul 2006
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Array Problem

    I see what I was doing wrong. Instead of setting the counter to the current x index I was setting the counter to the x dimension (the size of the array).

    Jason

Similar Threads

  1. Binary array problem
    By keokeo in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 8th April 2011, 09:48 AM
  2. Array/Simulation problem
    By Iwantmyrpg in forum File Archive
    Replies: 0
    Last Post: 2nd February 2009, 03:08 AM
  3. Array problem
    By Mephistus in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st September 2008, 02:51 PM
  4. Playback from an array.... Big problem... help \o/
    By TwistidChimp in forum The Games Factory 2 - Technical Support
    Replies: 13
    Last Post: 25th May 2007, 03:24 AM
  5. Array Problem pls help
    By Jaeu in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 10th October 2006, 06:48 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
  •