User Tag List

Results 1 to 6 of 6

Thread: Access different objects from a loop

  1. #1
    No Products Registered

    Join Date
    Mar 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access different objects from a loop

    Hi everybody,

    I'm trying to program 10 different objects which the player can walk around. Basically, as long as the player character's y-coordinate is below that of the object he is drawn in front of it, as soon as it is above that of the object he is drawn behind it.

    I set up my 10 objects as active objects. Whenever the player character moves vertically on the screen I want to check whether his y-coordinate relative to each of the 10 objects has changed and then modify his ordering in relation to the affected object.

    Here is my problem: Is there a way I can do this with a fastloop? Something like:

    1. Start Loop "Walkbehind" "number of obstacle_object" times

    2. On Loop "Walkbehind"
    if Y("player") < Y("loop_index("walkbehind")")
    ---> do something to Object("loop_index("walkbehind")")


    I don't want to create 10 sets of events, one for checking each object. The problem with fastloops seems to be that I don't know how to access each of the objects y-coordinate seperately and then only modify the players character's order in relation to that one object.

    I tried to put the objects into one group of qualifier but that didn't help me because you don't have access to single objects within the qualifier group.

  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)

    Re: Access different objects from a loop

    Give your objects and id by spreading 0 to one of the alterable values at start of level.

    On each loop, test if id equals the loopindex, and then perform the action.

    But there's an easier way to do what you want. Simply use the layer object's sorting feature and sort by Y decreasing

  3. #3
    No Products Registered

    Join Date
    Mar 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Access different objects from a loop

    Thanks for your answer, Popcorn

    The layer object's sorting feature is exactly what I was looking for.

    I also tested the ID spreading method and it works perfectly. Although I don't need it now, it is definitely good to know for the future.

    Thank you very much

  4. #4
    RayMarble
    Guest

    Re: Access different objects from a loop

    What I usually do is to put this into the "Joe" object:

    Y("Joe") > Y("Ralph")
    (under the "Joe" object): Move in front of object "Ralph"

    and

    Y("Joe") < Y("Ralph")
    (under the "Joe" object): Move behind object "Ralph"

    It's a bit basic, but it always works nicely... I guess it must go against some common sense in MMF programming, since it looks like the experienced users never use it. I guess I'll find out for myself when things start crashing!

  5. #5
    No Products Registered

    Join Date
    Mar 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Access different objects from a loop

    Well RayMarble, your code is perfectly okay.
    The only thing is, if you have more objects than just "Ralph" you would have to create a seperate check for each one of them.

    Y("Joe")>Y("Ralph")
    Y("Joe")<Y("Ralph")

    Y("Joe")>Y("Steve")
    Y("Joe")<Y("Steve")

    Y("Joe")>Y("Bill")
    Y("Joe")<Y("Bill")
    ...


    By using one of the methods which Popcorn suggested you could put all of that in as few as one single event.

  6. #6
    RayMarble
    Guest

    Re: Access different objects from a loop

    Heh that's true, I have all the characters always following the same path (more or less) and except for overlapping with the player character there aren't that many complicated situations.

    Since the layer object has the "sort by Y", I guess I should use it - otherwise I'll end up in trouble if I have more than 5 objects and have to sort them all manually... Although I wanted to use the least possible number of objects for the project it won't do to make things simpler than they should be (as a famous guy said Thanks

    _O_ (kowtow)

Similar Threads

  1. How to loop through objects!
    By Keli in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 30th December 2013, 12:48 PM
  2. Replies: 7
    Last Post: 25th December 2012, 11:26 AM
  3. Picking Single Objects and Fast Loop Trouble
    By Kid_Roleplay in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 9th September 2009, 01:25 AM
  4. Create objects next to each other loop
    By Raylax in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th December 2008, 06:16 PM
  5. (Help) creating objects durring a fast loop and...
    By nightofgrim in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 27th July 2006, 06:46 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
  •