User Tag List

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

Thread: Creating objects and saving memory

  1. #1
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)

    Join Date
    Nov 2014
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Creating objects and saving memory

    I'm doing some (hopefully) final tweaks on my project, but in trying to optimize it as best as possible for all platforms (basically PC and mobile), I've run into a conundrum.

    I need to be able to continuously create enemies on screen, for the player to destroy, but also destroy any unused enemies, when they wander off screen, take relieve memory.

    Here's an example of how I set it up.

    fp_event.png

    I use the "NObjects < xx" to prevent entire clusters of these guys from forming on screen. But that creates a problem, if more of them wander off than the player is able to destroy. I need to constantly create enemies until the score reaches a certain number. Setting the limit too high, creates more enemies than is needed, and creating too little, causes the all activity to cease before the the desired score is reached.

    I'm possibly overthinking it, but I've wracking my brain for days trying to figure this out.

    TL; DR Need to constantly create objects without slowing down the game too much.

  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
    495
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Have you tried setting the score as another Conditional? So, right now you have "NObjects < xx" but you don't have "Score < yy." You can then set the needed score (yy) to be dynamic in a separate event, based on the number of flies on screen.

  3. #3
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)

    Join Date
    Nov 2014
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually never thought of that. The only real conditional that I have regarding the score, are the events that happens once that score is reached. So would I set that "Score < yy" where "yy" = the required score?

  4. #4
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)

    Join Date
    Nov 2014
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I gave that a try, but this time the flies disappeared altogether. I'm also willing to entertain the very real possibility that I did something wrong. What I did was:

    *NObjects < xx
    *Hit Count < yy
    * Every 00"-xx
    **Create object at (position)
    **Set X Position to Random(Frame Width)
    **Set Y Position to RRandom(50, 280)

    Is that what you were suggesting dsilvers?

  5. #5
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleInstall Creator ProUnicode Add-on
    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)

    Join Date
    Jul 2006
    Posts
    573
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You could also just re-position the flies as they leave the screen instead of destroying them and recreating another. Also check that you have increased the object count in the frame properties.

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleMac Export Module
    dsilvers's Avatar
    Join Date
    Jun 2008
    Location
    Boston, MA
    Posts
    495
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    I think your problem is the timer. If you want all the flies on screen at the start, you should run a Fast Loop that either creates all the flies at once (less recommended), or run it once per event while the NObjects is still lower than the target amount (so you'd do On Fast Loop -> Stuff Here + Run Fast Loop). Because of the "NObjects < xx" in the event, the fast loop won't run more times than it has to.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,265
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    If this is for mobile I would recommend you create a large pool of enemies and hold them offscreen at Start of Frame. Then instead of creating an enemy when you need one you simply choose one from offscreen and reposition it. Same thing for when you destroy and enemy. You move it offscreen instead. I tend to set a flag ON to identify “active” enemies and OFF to identify enemies in the pool.

    This method is handy for anything you create and destroy a lot (fx particles, bullets, etc). If you create and destroy often you could very well run into RAM issues.

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,265
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Per your PM request, here is a basic object pool example. You can use this setup for simple things like particles or coins or whatever. Just make sure you create enough duplicates at the Start of Frame for your needs. If you use them all at once on screen, then nothing will appear when the game attempts to grab another one. If you need the pool to contain a lot of different objects, just put all the objects into a Qualifier group and change the code to use qualifiers.

    Keep in mind, when you recycle your objects back to the pool, you should take care to return all Vars, Flags and Animations to their default state. I find it is better to do this when you recycle them.

    object_pool.mfa

  9. #9
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)

    Join Date
    Nov 2014
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks! I'm just wondering, though.

    Thanks @mobichan , I like this a lot. My only issue is, I'm not sure how to go about recreating the current "swarm" effect that I have using the timers, and creating and destroying. That's what I'm after; the illusion of a swarm of critters invading the area that player must knock off one-at-time, to wrack up points. When I do it the current way, I have

    +Every 00"xx
    - Create Fly at (-15, 72)
    - Create Fly at (-16, 283)
    - (Fly) Set X position to Random(Frame Width)
    - (Fly) Set Y position to RRandom(50, 300)


    Also, I see that in the example you posted, that a double-click is what triggers the objects to appear on screen. I know timers slow things down in mobile apps, so I'm wondering if I should perhaps use global values as a timer?

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,265
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    You can replace any create action with the pick one at random event line I have in the example. You don’t need to use the timer var I made. That was specifically to show an automated way to recycle things to the pool. You can recycle any way you want.

    Not sure what you are saying about slowdown. I use tons of vars that count down like timers and have no issues.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Does creating objects at runtime use a lot of memory?
    By Simflare in forum Android Export Module 2.5
    Replies: 3
    Last Post: 6th March 2014, 02:38 AM
  2. Saving on Memory - Cutting Up Objects
    By Corlen in forum Android Export Module Version 2.0
    Replies: 4
    Last Post: 24th April 2013, 05:55 PM
  3. Crash: Destroying and creating text objects (memory issue)
    By Popcorn in forum Android Export Module Version 2.0
    Replies: 11
    Last Post: 30th March 2012, 11:35 AM
  4. [request] saving to memory
    By Grim in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 7th January 2008, 02:17 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
  •