-
Is it possible to truly create/delete objects...
... during runtime?
"Create object" only duplicates, and "destroy" doesn't really free memeory. Anyone know anything useful about this?
I am especially interested in freeing memory from objects that aren't used at some point during the runtime, without having to change frames etc.
-
Re: Is it possible to truly create/delete objects...
If you put deactivate when out of play area on in the properties then this should free up your memory.
-
Re: Is it possible to truly create/delete objects...
I tried that but apparently that helps with cpu usage, not memory. All objects within a frame are loaded from the start whether they are visible or 100000 pixels away from the window.
Anyone know if there is a way to conserve memory by creating/deleting objects during runtime or not?
-
Re: Is it possible to truly create/delete objects...
i don't think it would really be possible to do either: if you create a completely new object that's not just an instance/duplicate of an existing one, there wouldn't be any way of giving it code. if you truly deleted objects then it would be impossible to create new instances of that object from then on because you'd lose all information associated with it
-
Re: Is it possible to truly create/delete objects...
Thanks for the info Jacob and xyzzy. I guess I'll have to deal with this by loading small-sized animation frames to active objects when they aren't visible.
-
Re: Is it possible to truly create/delete objects...
Doesn't "load on call" have something to do with this? Never used it but I read about it somewhere.
-
Re: Is it possible to truly create/delete objects...
Are you wanting to free memory because you know you need to, or because you think it would be a good idea? Because if you don't know for certain that you use "too much" memory, then you're prematurely optimising. Especially as loading / unloading frames is fairly slow, is the memory saving worth it?.
-
Re: Is it possible to truly create/delete objects...
camelman
I tried that now, half-works, because I create the object during runtime, naturally the memory usage increases, but when I destroy it the memory stays the same doesn't go back down. Any other ideas?
Also I would like to ask, does anyone know if the expression calculator reads this:
"C:\Users\keo\Desktop\New Folder (2)\New folder\"+Str$(1-2)+".png"
...as:
C:\Users\keo\Desktop\New Folder (2)\New Folder\Str$(1-2).png
..this? I want to use an expression to dynamically calculate the path to a .png file to load as an animation frame but it doesn't work.
edit - Dynasoft, I'm not there yet, but I'm fairly sure I will need to keep the runtime as tidy as possible.
-
Re: Is it possible to truly create/delete objects...
Str$(1-2) is "-1". It does the calculation (1-2) and then converts it to a string.
What are you trying to do?
-
Re: Is it possible to truly create/delete objects...
Dynasoft
I am trying to load multiple animation frames on an active object during runtime, using a fast loop that includes the "load frame" function, a global value.
-
Re: Is it possible to truly create/delete objects...
So you're not actually using Str$(1-2)? What is your expression?
-
Re: Is it possible to truly create/delete objects...
This is the exact expression I am using:
"C:\Users\keo\Desktop\pngsequence\animation"+Str$( Global Value E)+".png"
The loop also adds 1 to the global value since my png frames are named as such:
animation0.png
animation1.png
animation2.png
and so on.
-
Re: Is it possible to truly create/delete objects...
Why don't you use Str$(LoopIndex("Loop Name")) ?
-
Re: Is it possible to truly create/delete objects...
Thanks, that semi-worked, it loads the first frame of the animation, but not the rest, or at least I'm not seeing an animation when I trigger via the "start" animation function. Any ideas about that?
-
Re: Is it possible to truly create/delete objects...
Ok I got it, I had to add more frames to the active object (not runtime). Thanks Dynasoft, your help was massive.
-
Re: Is it possible to truly create/delete objects...
"C:\Users\keo\Desktop\New Folder (2)\New folder\"+Str$(Global Value)+".png" is what you're after.
But, you should use a relative folder rather than an absolute path, unless you're the only one ever going to use your app.
For example, if the images are in a subfolder "images", you could just put:
"images\"+Str$(Global Value)+".png"
-
Re: Is it possible to truly create/delete objects...
Namida
If I were to put "images\"+Str$(Global Value)+".png' only, would the program find it without the need of puting the rest of the path?
In general how do I create relative paths instead of absolute ones to avoid (as you said) problems when other people run the program on their pcs?
-
Re: Is it possible to truly create/delete objects...
You're both right --
You should have relative paths, but images\"+str$(Global Value)+".png" won't be found
You'll need AppPath$+"\images\"+Str$(global value)+".png" ... well I'm not sure if AppPath$ returns a \ at the end, so do some testing :)
-
Re: Is it possible to truly create/delete objects...
Thanks Ricky. Do you perhaps know of any other such keywords that can be used to construct relative paths(like AppPath$)? They might come in handy for future use.
-
Re: Is it possible to truly create/delete objects...
There's also AppDrive$ and AppDir$ I think. Whatever they're called, you can find them under the expression editor retrieve data from special object. One is the drive letter, the other is the path not including drive letter. In previous versions of MMF you had to use both of these, as AppPath$ didn't exist yet.
-
Re: Is it possible to truly create/delete objects...
If you don't include AppPath$ the application will look relative to the current directory, which by default is the application directory. So using just "images\"+str$(Global Value)+".png" will work perfectly fine as long as nothing changes the current directory.
-
Re: Is it possible to truly create/delete objects...
AppPath$ does indeed return a "\" as the last character.
AppDrive$ + AppDir$ should be avoided, because some times your application will be run from a network location that has no letter.
-
Re: Is it possible to truly create/delete objects...
Quote:
Originally Posted by Werbad
If you don't include AppPath$ the application will look relative to the current directory, which by default is the application directory. So using just "images\"+str$(Global Value)+".png" will work perfectly fine as long as nothing changes the current directory.
I didn't know this :)
What's the point of AppPath$ then?
-
Re: Is it possible to truly create/delete objects...
Same as AppDrive$+AppDir$ (put together) but also works with network paths. I assume the only reason they kept the old is for backwards compatibility.
-
Re: Is it possible to truly create/delete objects...
I know Dynasoft, but what's the use if you don't even need it?
-
Re: Is it possible to truly create/delete objects...
It also works with network paths? It's shorter?
-
Re: Is it possible to truly create/delete objects...
NO. I mean like if you can just do what Werbad said:
Quote:
Originally Posted by Werbad
If you don't include AppPath$ the application will look relative to the current directory, which by default is the application directory. So using just "images\"+str$(Global Value)+".png" will work perfectly fine as long as nothing changes the current directory.
Why have the AppPath$ at all? Just leave it blank.
-
Re: Is it possible to truly create/delete objects...
What if you needed to store the location of your app somewhere for another app, RickyRombo? :p
-
Re: Is it possible to truly create/delete objects...
I mean it has purpose I guess, but... idk...
/me exits the thread