User Tag List

Results 1 to 8 of 8

Thread: Launching several ForEach loops for every single object

  1. #1
    Clicker Multimedia Fusion 2 DeveloperAndroid Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Neoqueto's Avatar
    Join Date
    May 2008
    Location
    Koszalin, Poland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Launching several ForEach loops for every single object

    Hello everyone. It's my first post here.

    So, basically I downloaded (from a polish site) an example showing how to make falling boxes (unfortunately I don't have it anymore in its original form and the download link is dead...). It was based on fast loops and worked well, but it was quite laggy with a huge number of objects, so I attempted to convert all of it to ForEach loops. And it worked, but in the original example boxes were falling much faster. Fast loops were run 10*NObjects("box") times and by that I mean 10 times per box. Per every single loop's iteration objects moved 1 pixel down the Y axis - of course I could make them fall by 2 pixels or more, but that still would be too slow and it would begin to be inaccurate.

    So here's my question: is there a way to run more than 1 ForEach loops per one object? Or, is there another way to speed up my boxes and keep it accurate? I'd really prefer an efficient solution to this problem. I did try "Set ForEach loop's iteration", but apparently it does something else... or doesn't work at all. I tried launching fast loops from ForEach loops, but it's a bit too complex.

    Thanks in advance.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS 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)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Hey and welcome to the forums!

    I'd do it by running fastloops within ForEach loops, as you suggest. On ForEach, before starting the fastloop, set a counter to the fixed id of the current Object to keep track of which Object is currently running the ForEach.

  3. #3
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    944
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Is ForEach really as easy as they say? Every time I try to use the extension it never works and I end up going back to Fastloops. Is there some really simple tutorial on how to use it efffectively someplace?

    Thanks in advance

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    ForEach really is easy to use. Do not use fastloops for object selection instead of ForEach loops. Fastloops have their purpose, but it isn't looping through every copy of an object. It makes performance drops increase exponentially with every extra instance of an object you are looping through like that. ForEach loops, on the other hand, don't have that flaw. They may be a little bit difficult to grasp at first, but they really are easy to use. I believe the ForEach object comes with some examples, you may want to look at them if you haven't already, since they are very useful.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperAndroid Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Neoqueto's Avatar
    Join Date
    May 2008
    Location
    Koszalin, Poland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Popcorn: Yeah, it seems like the only option. The reason it's hard to implement is that in the events responsible for collision detection there are other conditions that relate to the box objects and ForEach deals with it like a breeze all by itself... But how can I accomplish it in fastloops? The example also utilizes detectors (well, a single detector actually) and that just... messes everything up even more.

    I found the original example: http://romanx.webd.pl/down/grav+.zip . It's pretty old, well, it's a .gam file after all, it requires the old TGF Fast Loop extension and by the way the author herself isn't very proud of this one. Anyway, first I replaced all the events related to that extension to built-in MMF2 fast loops, then I tried the ForEach thing, also replacing pretty much everything. Here's my version of that example, download this one if you want to: https://www.dropbox.com/s/sps2ljtxzg...ified.mfa?dl=0 . As you can see in the 3rd frame - the simple and most obvious solution won't work, because MMF2 isn't told which crate object the detector should be placed at during each loop's iteration. If there was an option just to place both the fast loop condition and the foreach condition in the same event... At this point, I'm stuck.

    @Del_Duio: as happygreenfrog says, it really is easy to use and the whole extension is so miraculous that it's been implemented into Fusion 2.5. Again, what ForEach does is just it performs the same action for each given instance of an object and sort of treats all of them individually, from a practical point of view. As a loop, it's much more efficient in iterating through objects than fast loops & spread value, but that's been already explained.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS 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)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Neo, I tried with the method I suggested in my other post, and it works. Did you try it yourself? On ForEach, before running the fastloop, set a counter to the fixed id of the box. Then on each onLoop event, compare the box's fixed id to the counter's value.

  7. #7
    Clicker Multimedia Fusion 2 DeveloperAndroid Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Neoqueto's Avatar
    Join Date
    May 2008
    Location
    Koszalin, Poland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I tried your method earlier, but it didn't seem to work. I tried it again just a while ago, and once again it turns out that the order in which you compare values actually matters. It works wonderfully now . Set alterable A of "detector" to fixed of "crate" at the beginning of the loop, then in each event compare: fixed of "crate" = alterable of "detector", not alterable of "detector" = fixed of "crate". Thanks a ton for a sample of your infinite wisdom, Popcorn!

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS 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)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    No problem, Neoqueto! I'll hand over samples of my infinite wisdom any time!
    I'm glad you got it working
    Order of comparisons, conditions, actions and events are all very important in Fusion. It can be confusing in the beginning, but once you've experimented enough failure it should eventually come to you.. hehe

Similar Threads

  1. Nested ForEach loops?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th March 2017, 05:05 PM
  2. How to stop ForEach loops in 2.5?
    By Allrounder in forum Fusion 2.5
    Replies: 14
    Last Post: 31st March 2015, 03:09 AM
  3. Nested Foreach loops
    By Pixelthief in forum Fusion 2.5
    Replies: 6
    Last Post: 8th June 2014, 05:52 AM
  4. ForEach loops on Xbox 360
    By jchristiansen in forum XNA Export Module 2.5
    Replies: 4
    Last Post: 15th April 2014, 07:53 PM
  5. ForEach Loops fps issue!
    By piscesdreams in forum Android Export Module 2.5
    Replies: 5
    Last Post: 24th January 2014, 01:23 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
  •