User Tag List

Results 1 to 10 of 10

Thread: find absolute x position?

  1. #1
    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,310
    Mentioned
    97 Post(s)
    Tagged
    0 Thread(s)

    find absolute x position?

    Hi. I have a scrolling game with a frame of 10,000 x 6,000. I'm using the "layer object" to get a parallax effect. I have space ships that fly across the background, travelling the whole 10,000px from left to right. They do this slowly, using a rubberball movement set in one direction. I want them to be destroyed when they leave the 10,000px area.

    So, I've got "if x position of spaceship is greater than 10000 > destroy spaceship". The problem is, that the x position of the spaceship seems to be always relative to the scrolling frame in some weird way.

    When I run the game with the debugger, the x position of the ship slowly increases as it moves to the right. But the speed that it increases by shoots up when I move my character (and hence the screen) to the left. If I move my character to the right, the x position of the ship actually decreases, even though the ship is still moving to the right (offscreen). I have a lot of ships, and as a result, they tend to get destroyed in weird clumps, mainly if my character happens to be on the right end of the map.

    Is there a way to get the x position of an active object that is absolute (aka relative to the frame), and won't be affected by scrolling or character movement? Checking/unchecking "follow the frame" doesn't seem to affect this. Also, using the "destroy if too far from frame" option doesn't seem to be solution, because it seems to destroy things when they are off-*screen*, and not just off-*frame*.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform 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)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,117
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    is your ship definitely on the layer you think it is?

    if it is, one thing you can try - create an active object (called say, Object01) and place it at X0 on the same layer as the ships - also make sure the object is never destroyed, then compare the ships to the X position of that object at X0. Eg. X of spaceship > X of Object01+10000 - destroy ship.

    I know this is the same thing you're already doing (except using an object instead of the built in frame events) but I suspect that this will work with no problems.

  3. #3
    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,310
    Mentioned
    97 Post(s)
    Tagged
    0 Thread(s)
    "is your ship definitely on the layer you think it is?"

    I don't follow your thinking. Why would it matter what layer it's on? I'm not comparing it to any other layer other than the frame itself. At any rate, shouldn't the "x position" of an object relate either to:
    (a) the layer that it's on (whichever layer that happens to be)
    or
    (b) the base frame of the entire scene (ie. the large white area in the frame editor)?

    Yet my ships' "x positions" don't seem to relate to either of those.

    I've actually got ships on several different layers (ie. in the distant background, in the midground, in the foreground etc.), moving at different speeds. I'd like them all to be destroyed at a certain point. The problem is that there's no such thing as a "certain" point, because their x position fluctuates wildly depending on where the camera happens to be. I find this weird. btw, this also happens if I put them on my main, 'central' layer, which has a normal 1:1 ratio of scale, rather than the background layers which have a different ratio for the parallax effect to work.


    "if it is, one thing you can try......"

    That's a decent workaround. I just tried it, and it seems to work. Though it's still weird, since the new marker object also has a wildly fluctuating x position dependent on the camera (but since it fluctuates in the same manner as the ship, the ship's position can be reliably gleaned from it). My main issue with this method though is that I'd have to create a new marker object for every layer that I put moving things on, which is extra work and extra complexity that I'd like to avoid if possible.

    Is the behaviour I'm describing expected? I feel like I'm making some really obvious mistake or something.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform 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)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,117
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I assume you're playing with the X/Y offsets of the layers if you're using layers to create a parallax effect. If for instance, one layer has an x coefficient of 0.5, you're not going to 1:1 x positions of an object on a layer with an x coefficient of 1.0

    It is kind of hard to understand how you've set it up.. if you can post an mfa demonstrating the problem it would be easier to help.

  5. #5
    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,310
    Mentioned
    97 Post(s)
    Tagged
    0 Thread(s)
    I'm using the layer object, and yes, it uses coefficients. But like I said, the problem also exists on the 'central' layers that are at 1:1, and not just the background or foreground layers. Besides, I don't see why it's comparing a layer with the camera in the first place. Anyway, I'll work up an mfa tomorrow.

  6. #6
    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,310
    Mentioned
    97 Post(s)
    Tagged
    0 Thread(s)
    Ok, I've made an .mfa

    The ship is told to stop when its x position hits 2500. Now try this:
    1. run the frame, and hold down the right arrow key to race ahead of the ship and wait for it at the red line.
    2. close and run the frame again. This time, stand still and wait about 8 seconds to let the ship reach the red line, then go and join it
    3. Do #1 again, but once the ship reaches the red line, repeatedly move your character left and right and observe the ship.


    In #1, you should see the ship stop at the red line perfectly. In #2, it will have gone way too far. And in #3, it does all sorts of weird things.

    Now, the ship and the red line are on different layers with a different layer parallax coefficient, so you might argue that getting a ship on layer 1 to stop at a red line at layer 2 makes no sense because they're both moving at different relative speeds. But what if instead of stopping it at the red line, I want it to stop at the very end of the gameworld? In other words, what if I put that red line all the way to the right of the frame and tell the ship to stop there, so that it doesn't travel off my gameworld? That seems like a pretty reasonable and straight-forward request, right? Well, I'll have the same problem with the ship not always stopping where I want it to. So my question is: how can I reliably tell the ship to stop where I want it to, in relation to the base frame of the game? Do I need to make an equation that takes into account not just the ship's position, but its layer's position? Is there a simpler way?

    I dunno, maybe this stuff doesn't really matter and I'm getting too caught up in it . But at the moment I'm just confused by it, and I'm concerned that if I don't understand what's happening, it might come back to bite me in the butt later.
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform 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)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,117
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I had a bit of a play around with it, it is strange - is this what you're after?

    paralax test 2.mfa

  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,310
    Mentioned
    97 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately that doesn't solve the problem. Or, to be precise, it masks one problem, but allows other problems to still happen.

    Let me explain. In my game, I actually want a steady stream of planes to fly in the background every X seconds. I've updated the mfa below to launch a continuous stream of planes instead of just one. Maybe I should have done this initially. Anyway, try this:

    -load the frame of the new attached mfa
    -Planes will launch every 0.5 seconds, and stop at 2500.
    -Wait for a few planes to reach 2500, then go and join them at the red line. So far so good.
    -Now, move the character left, back to the beginning. Suddenly, there isn't a nice neatly timed procession of planes anymore. Instead, they are grouped together in ugly clumps.

    Again, the problem seems to be my inability to control the planes' position according to *their own layer*, independently of the camera's position.
    Attached files Attached files

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform 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)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,117
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    yeah, it's kinda tough to know exactly what is going on.. It seems like you say, Fusion is not referencing the x position on that layer but on the scrolling layer, so you get some weird results. The only way I can think to make it work is to use an active object on the same layer at X0 and reference the X distance from that object.

  10. #10
    Clicker Fusion 2.5

    Join Date
    Sep 2010
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try "if x posiution of 'spaceship' = frame right edge + 'spaceship(width) ---> destroy

Similar Threads

  1. Absolute value
    By falkon in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 23rd May 2017, 02:20 PM
  2. how do you do absolute values in the formula?
    By dascribe in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 1st September 2012, 07:41 PM
  3. Absolute Position
    By glauberdmo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 27th August 2010, 01:21 AM
  4. Absolute Value
    By InsertNameHere in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 1st May 2008, 11:46 PM
  5. Getting Frame rate to Absolute 0....Impossible?
    By Zenoff64 in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 11th April 2007, 11:24 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
  •