User Tag List

Results 1 to 7 of 7

Thread: Loading external files during run time - is it possible/a good idea?

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loading external files during run time - is it possible/a good idea?

    This topic is somewhat related to my questions about hadling collision masks.

    What I want to achieve is this:

    1. Storing files in some sort of archive, that cannot be opened (at least not easily) by a user.
    2. Reading the files from the archive during run time (for example, loading the background for the current frame, or the music of an area).
    3. Reading smaller files (less than 100 kB) should ideally not cause any lag at all (provided I don't try to load them several times inside a fastloop of course).

    The reason I want to do something like this, is that I am making a game that will have a lot of rooms (metroidvania style).

    I do not want to create one frame for every room (could end up being 50-100 frames), since the code will become a nightmare to maintain. Therefore I want the gameplay part of the game to reside in one frame only, and to do this I need to load room layouts, enemy graphics, music and so on dynamically during run time.

    With simple graphics, just putting everything in the game and loading it as the frame starts is a possible option, but for greater projects I really don't think putting everything into the executable is a good idea. Ideally, I would like somehing like the MPQ files of Blizzard's games (the earlier ones, at least) .

  2. #2
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A small update. I found out that the Active picture object can be used to load external pictures, and it works pretty much the way I want to. There is no lag when loading a new room from it, but at this time all images are stored in a normal folder. This means that the user can play around with the images and watch them outside the game, which is not really ideal. If there is any way to do this, but with an encrypted archive instead, I would be very happy

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator

    Join Date
    Jul 2006
    Posts
    1,018
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest way is to include external files in the EXE. In the case of graphics you can save them in a sub-folder of your project MFA file and connect them to your app. You just have to do this in the Data Elements window (Menu > View) on the tab Binary Data. If you now build the EXE all files included in this window are inside the EXE file. You can have easily access to this files via the events. If one added file's path is "D:\files\test.png" you just have to load the file "D:\files\test.png" in the Picture or Active object at runtime without extracting them before. That's a very easy and comfortable way. Another good thing is the reduced size of the EXE file. As far as I know MMF stores images uncompressed in the EXE file. If you store the images separately as PNG as mentioned before you can also save a lot of space.


    Another way is to use the Archive object. Put all your images inside one or more zip file(s) with encryption and password protection. Then the action Quick Extract File From Archive gives you the ability to get the file you want without extracting all other files to disk. This should be a little slower than the first method because the files has to be extracted on disk first.

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Gustav!

    I created a separate application for loading files into a graphics archive. Then, during run time, I can quick extract images on the fly and paste them as obstacles or use them as decorative graphics using the Active picture. I was a bit worried that once the archive gets big, extracting would be slower, but I noticed no lag even after I put a 150 MB movie file into it. Considering the png:s I am using in the project are like 10-50 kB each, there will likely be no issues at all using this method.

    Thanks again for the help! This opens up so many possibilities.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator

    Join Date
    Jul 2006
    Posts
    1,018
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome. I'm glad to help you.

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a question regarding the binary data solution. If the data added this way is stored inside the exe - will all images load as the exe is run or will they only load when actively called upon from some event?

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator

    Join Date
    Jul 2006
    Posts
    1,018
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tested this behavior some time ago but I can't remember the result now. But I think every image is only loaded when used. I think even a very large EXE file starts fast because it just loads what it needs.
    You can test it very easily with the Debugger. Just load and release different images in objects and destroy them again and watch how the memory value changes.

Similar Threads

  1. Problem with frame editor - loading files all the time
    By J3sseM in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 3rd October 2013, 07:39 AM
  2. Loading external files question
    By mobichan in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 17th July 2012, 02:43 AM
  3. Active Object loading external files?
    By Chokito in forum Extension Development
    Replies: 13
    Last Post: 25th July 2006, 10:26 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
  •