User Tag List

Results 1 to 9 of 9

Thread: For each loop pairing with object

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question For each loop pairing with object

    I need some help with pairing of two objects.

    I know how to pair an object with another object using for each loops and fixed value.

    For example:
    I create an enemy, then i create that enemy's shadow and pair the shadow with the enemy's fixed value. This pairs the SHADOW with the ENEMY.
    issues.jpg

    My question is:
    How do i pair the ENEMY with its paired SHADOW?
    How do i retrieve the already paired shadow's fixed value and store it into an alternable value in the enemy?

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,308
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    The simplest way is to create the object at runtime and then the secondary object in the same event line. Then set the var of the secondary object. Something like:

    +Some condition:
    -Create Enemy
    -Create Ground Object
    - Set var(Ground Object) to Fixed (Enemy)

    Once the var is set, you can use the forEach loop in your image.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    264
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like this?
    solution.jpg

    like i said. what i want to do is pair the Enemy with it's already paired ground object, so that both objects have eachothers fixed values.

  4. #4
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,308
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    I am not sure why you would want this, but a simple way would be the following:

    +Some Condition
    - Create ObjA
    - Set tempObjAFixed to Fixed Value (ObjA) <-----(tempObjAFixed is an additional variable you need to make)
    - Create ObjB
    - Set parentFixedVar(ObjB) to Fixed Value (ObjA)
    - Set tempObjBFixed to Fixed Value (ObjB) <-----(tempObjBFixed is an additional variable you need to make)

    +Some condition
    - start ForEach loop "TransferFixed" for (ObjA)

    +On ForEach "TransferFixed" for (ObjA)
    +Fixed Value (ObjA) = tempObjAFixed <---- (this should be a "compare fixed value" action NOT a "compare 2 general values" action)
    - Set parentFixedVar(ObjA) to tempObjBFixed

    It is a little complex and probably confusing to read, but the idea is that you need to store both fixed values into some temporary variables. Then you run a ForEach loop on all ObjA's and check which one has the fixed value that was last stored in the temporary variable. Then set the proper Fixed Value from ObjB (which is stored in a temp variable) to ObjA. But be careful not to include any ObjA conditions in the event line that starts the ForEach loop. Otherwise it may scope the ObjA selection in a way you don't want. This is also why I activate the ForEach on a new line, instead of lumping it in at the end of the first event line.

  5. #5
    Clicker Fusion 2.5 DeveloperHTML5 Export Module

    Join Date
    Jun 2006
    Posts
    1,465
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    It sounds like you need to create a Link Table with two fields, Enemy and Shadow. After creation and pairing you add a record to the table containing the Enemy and its Shadow's fixed values. I don't know if you need to save the table or not but you could.


    Anyway this is just a rough idea and there may be a better extension to use. You could create two different tables to speed lookups. Well just brainstorming.

  6. #6
    Clicker

    Fusion 2.5Android Export Module

    Join Date
    Jan 2007
    Posts
    278
    Mentioned
    8 Post(s)
    Tagged
    1 Thread(s)
    You want the enemy and the shadow to have the same ID?

    Don't use fixed values as they can be confusing to compare against. Use an alterable value. I do this in virtually every project I work on and work with paired shadows regularly.

    I usually reserve value Z for object IDs. I'll make a commented example if I remember once I'm home.

  7. #7
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Just don't.
    ForEach loops definitely have their uses for more complicated tasks, but stuff like this is so easy to do just by letting CF2.5 pair the objects automatically.



    Updating the shadow's position, angle, animation etc couldn't be simpler:

    + always
    -> shadow: set position at 0,0 from object
    -> shadow: set direction to direction("object")
    etc



    If you have to delete an object and its shadow:

    + something happens...
    -> object: set deleteMe to 1
    -> start loop "deleteObject" 1 time

    + on loop "deleteObject"
    -> shadow: set deleteMe to deleteMe("object")

    + on loop "deleteObject"
    + object: deleteMe = 1
    -> object: destroy

    + on loop "deleteObject"
    + shadow: deleteMe = 1
    -> shadow: destroy


    If you give the objects and shadows an "ID" variable and set it using "spread value", paired objects and shadows will automatically always share the same ID.

  8. #8
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,308
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    Along MuddyMole’s line of thinking you will also possibly need to run the delete loop “number of enemies” times. This would only be necessary if more than one enemy is destroyed on the same frame. But better safe than sorry.

  9. #9
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    That's true, although in practice, there's a very good chance that the event which triggers the destruction of the object, would be run inside a ForEach loop anyway - particularly when it comes to collision detection, which CF2.5 can't really deal with any other way if you have multiple instances of both colliding objects (you just don't need a ForEach loop to manage the pairing of an object and its shadow).

Similar Threads

  1. Replies: 4
    Last Post: 27th June 2018, 09:59 AM
  2. Replies: 21
    Last Post: 25th September 2017, 07:50 AM
  3. Conditional Object Pairing broken?
    By PotatoMerchantz5 in forum Fusion 2.5
    Replies: 4
    Last Post: 15th June 2016, 11:11 PM
  4. Pairing nearest objects
    By K_Tetsu in forum Fusion 2.5
    Replies: 9
    Last Post: 2nd September 2014, 04:30 PM
  5. Automatic pairing?
    By arsdigita in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 14th April 2011, 03:04 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
  •