User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: "Set Position" has small delay

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

    Join Date
    Dec 2012
    Location
    Copenhagen, Denmark
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Set Position" has small delay

    Consider the following code for an interface element (Hitpoints):
    +Always
    -Set X position to X("Enemy")

    This enemy can move around and fall down etc. The thing is, if the enemy is falling beyond a certain speed-limit (and this limit is quite small actually), the Hitpoint bar follows to the specified position, but it's kind of lagging behind. I run the application using Direct3D 9, V-Sync enabled and a framerate of 50.

    I'm curious if this is just one of the small things I have to live with, or can I fix this somehow?

    Thank you in advance!

  2. #2
    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,306
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    When are you setting the enemy to fall and move around? If you are setting it to move around after the event where you set the position of the health bar, then that is the problem. For example, if event 4 sets the position of the health bar, and event 5 moves the enemy, then you need to re-arrange it so that event 4 is moving the enemy and event 5 is positioning the health bar. The reason is because MMF2 reads the events in order, from top to bottom. As a result, you need to position the health bar after moving the enemy. Makes sense, right?

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

    Join Date
    Dec 2012
    Location
    Copenhagen, Denmark
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you that did the trick. I put all my interface code to the bottom and it looks fine now. There's only a sliiiiight movement on the healthbar now though, but this will do.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,541
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As a rule, remember that all code executes from top to bottom in the event editor. Events you have below other events will occur after those events. So if one object is repositioned, and you want to position another object like a healthbar relative to it, it has to be put lower in the code.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module

    Join Date
    Dec 2012
    Location
    Copenhagen, Denmark
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys for your input! I have a LOT of logic in my game so far, do you think it would be a good idea to put everything into fastloops? I do have some fastloops, but would everything run smoother if I put EVERYTHING into fastloops? I do comment all my sections though, so it would only be for performance, not to make the overall code easier to read...

  6. #6
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,541
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Fastloops don't implicitly slow down or speed up anything, they're just a method of formating your code. For MMF2.0, fast loops should be used with care with reference to their overhead- each fastloop run will see every other fast loop, so by enclosing them in groups which are activated/deactivated when called means the compiler doesn't have to sort through all your loops every time you run one. I explain how to do that in this article:
    http://create-games.com/article.asp?id=1937

    In MMF2.5 which will be out in a couple weeks, thats no longer the case. Fast loops with will be referenced explicitly- the compiler optimizes them by just telling the runtime to jump to that action in the code instead of searching each loop event and reading its string name. This will *not* work if your frame has *any* dynamically named loop events- only if every single fast loop in your event editor uses a static name. For example, if all your loops are named strings like

    On loop "PlayerLoop"

    Then MMF2.5 will do away with the need to optimize. However if you even have a single line of code that dynamically names it, such as

    On loop Alterable String A("Player") + " " Str$(Alterable Value A("Player"))

    Then bam, optimization no longer exists. The compiler just reads through your whole program and checks if you have any lines of code like this, and sets a global value to be true or false to use the optimations or not.




    Anyway, the choice of *where* and *when* to use fast loops is usually just a question of if you have any code which needs to run more than once per frame. If you need to do something 50 times, don't use 50 different lines with "always". If you have a specific function in one group you want to call many different times in other places in your code, using a fast loop can do that right. For a C or C++ programmer, its the same call as when to use a loop structure or not

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2012
    Location
    NSW, Australia
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, i never knew that PixelThief!
    Thanks for that post very informative, looking even more forward to Fusion 2.5 as theres less for me to worry about lol!!

  8. #8
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,541
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As someone who has ~400 groups in his project, many of them just as fast loop wrappers, it makes me shudder to think of how much time I could spend unraveling my code
    But its not like I'd make it any faster by ungrouping those events, so meh

  9. #9
    Clicker Fusion 2.5iOS 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)
    SolarB's Avatar
    Join Date
    Feb 2012
    Location
    Melbourne
    Posts
    904
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Actually when it comes to object iteration fastloops are much slower than using a bunch of Always events, ie:

    On loop "i"
    + id of active = loopindex "i"
    --> do stuff

    Is way slower performance wise than doing:

    id of active = 1
    --> do stuff

    to

    id of active = 50
    --> do stuff

    I tested this on iOS for one of my projects but of course I could still be mistaken as it's been a while since I've gone back and looked at it. Worth testing.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module

    Join Date
    Dec 2012
    Location
    Copenhagen, Denmark
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the clarification on Fast Loops, it's much appreciated.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Is "Save frame position" Safe to use?
    By Klownzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 26th August 2015, 05:39 PM
  2. Set edit box text to string$("string object") causes long delay
    By MJK in forum XNA Export Module Version 2.0
    Replies: 4
    Last Post: 22nd August 2012, 02:58 PM
  3. frame "slides" to a position instead of "jumping"
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 9th March 2010, 12:43 AM
  4. "Create at a random position"
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 25th September 2009, 01:51 AM
  5. "Load Frame Position" Crashes Application!
    By DistantJ in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 21st January 2008, 08:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •