User Tag List

Results 1 to 9 of 9

Thread: What is the formula to get the x cordinate on an object on a layer with a coefficient

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question What is the formula to get the x cordinate on an object on a layer with a coefficient

    I have a problem where I have an object on a back layer that I want to check if that object leaves the left side of the game (if x is lower than 0). However since that object is on a layer with a coefficient that is not 1.0 (say it can be 0.5 instead) when I check the x position of that object it is always changing depending on where I am when scrolling back and forth. How can I make it so it actually checks the x position of that object as if the coefficient was 1 so it is not changing all the time if that makes sense?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleMac Export Module
    dsilvers's Avatar
    Join Date
    Jun 2008
    Location
    Boston, MA
    Posts
    505
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Off the top of my head, run a Fast Loop each frame that sets a layer's coefficient to 1 (use the Layer object), then check the object position in that loop. If it's lower than 0, destroy it. Then at the end of the loop, set the coefficient back to 0.5.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCiOS Export ModuleInstall Creator Pro
    Julian82's Avatar
    Join Date
    May 2012
    Location
    outbuddies.com
    Posts
    922
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    @Outcast : just move your object to a layer with coefficient 1.0 before testing, then check/store coordinates, move back to original layer.

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,163
    Mentioned
    78 Post(s)
    Tagged
    0 Thread(s)
    I was keen to get this as a single formula too, so I could test it using a simple condition. It took me a while to figure out, but I believe I finally got there! The magic formula to see if any parallaxed object has gone off the left side of the game area is:




    I'm a bit less confident about the formula for testing whether something's gone past the right edge of the screen. Here's what I've come up with (it assumes the entire game area width is 1000.....that is, objects at x>1000 have left the game area):



    If someone could test these (especially the last one) to confirm they work, that would be great!

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    I don't know why, even though it sounds logical I can't get any of these methods to work

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    I think I found a way that works good for me though, instead of checking if the object is lower than an x position (in this case the very edge of the left frame = x = 0) I just positioned another invisible active at that position on the same layer and then compared my object to that object instead. So when my object is lower than that object (that object is position at x 0) then I trigger the event.

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,163
    Mentioned
    78 Post(s)
    Tagged
    0 Thread(s)
    That's what I used to do. The thing is, no matter what method you use, this stuff is ultra confusing, at least to me.

    Destroying an object when it goes beyond x works straight-forwardly enough for me, but when instead of destroying it you want it to wrap around from the other side of the game area, it gets weird.

    Where it considers the left edge of the game and the right edge of the game varies wildly depending on where the camera is in the game. That seems obvious enough, but it does it in a way that's not at all intuitive to me. For example if you start on the left of the game area and travel to the right, objects will terminate and/or wraparound differently than they do if you start on the right of the game area directly. And this is the case with all the methods mentioned thus far (swapping layers, using formula, using reference object)

    I've spent a day experimenting with this and I just can't get my head fully around how it works, even though it seems like it should be simple (and perhaps to someone else it would be.

    This issue has bothered me on and off for years, and I thought I'd finally solve it by tackling it head on all day, but I'm still somewhat stumped as to how to get totally predictable wrapping. I'm happy with the formula though. It seems to produce the same results as the layer-swapping method, but is cheaper

  8. #8
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,163
    Mentioned
    78 Post(s)
    Tagged
    0 Thread(s)
    I've also noticed that you can get vastly different results depending on where you have your "centre display at XXXX" event. For anything that references the frame positions (eg. my formula which uses X Left Frame), the "centre display at XXXX" event must be at the bottom of your events.

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,163
    Mentioned
    78 Post(s)
    Tagged
    0 Thread(s)
    OK, I believe I've found the correct formula for finding the right edge of the game area. I was unsure about the previous one I showed, and it did seem to be wrong upon further testing. This is what I've found to work, to the best of my ability anyway, which is not necessarily saying much. In this example, the full width of the game area is 10,000.



    The equation is essentially this:

    r = a - b + (b*c)

    where:

    r is the right edge of the game area, at any given time, regardless of camera position or layer scrolling coefficient
    a is the full width of the game area
    b is how much of the gameworld lies beyond the right edge of the screen (ie. full width minus X coordinate of right visible edge)
    c is the layer coefficient of the object in question.


    The first equation I showed, for the left edge of the gameworld, still appears to be correct. That one, incidentally, is:

    L = d -(d*c)

    where:

    L is the left edge of the game area, at any given time, regardless of camera position or layer scrolling coefficient
    d is how much of the gameworld lies beyond the left edge of the screen (ie. X coordinate of left visible edge)


    (sorry for the triple post - blame the dumb forum rules that don't allow edits after 60 minutes).

Similar Threads

  1. Blend Coefficient - Layer Options Help
    By kreeddem in forum Fusion 2.5
    Replies: 4
    Last Post: 24th July 2018, 10:01 AM
  2. Replies: 8
    Last Post: 7th October 2015, 11:32 AM
  3. Replies: 2
    Last Post: 19th December 2012, 11:49 PM
  4. Layer bug with coefficient 0
    By Nioreh in forum File Archive
    Replies: 5
    Last Post: 27th July 2006, 09:05 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
  •