Delete?
Blitz3D Forums/Blitz3D Programming/Delete?
| ||
Hello, I have a question, when using Delete is not necessary to remove any related entity type property?, For example.Type Cube Field Cub% End Type Local Cubo.Cub = new Cube Cube\Cub% = CreateCube() FreeEntity (Cubo.Cub); << << This is optional or mandatory? Delete Cubo.Cub |
| ||
I think you have to first delete all the pivots, the meshes, the textures, the animations sequences, the sounds, and then you can delete the instance of a type. If you only delete the instance of a type, the pivots, the meshes, the textures, the animations sequences, the sounds, will stay in memory. |
| ||
I write a dedicated function to do this:Function DeleteCube(c.Cube) FreeEntity(c\Cub) Delete(c) End Function If you create such a function every time you create a type that has entities, textures or whatever, your life will be easier. |
| ||
If it hel;ps, I'm pretty sure at least that CHILD entities ARE Freed when the parent is, but yes, Deleting an OBJECT simply frees the memory reference - which will then be inaccessible - so make sure to FREE the Entity handle BEFORE deleting the object instance!!! |
| ||
i believe.... that, as Axel W said, A dedicated function is the neatest way of deleting those TYPE fields. ;--------------------------------------------------------------- Also, there's no such thing as an "Each Entity" command for entities, so once you've lost track of your entity, ... you've lost it. Related logic: If you RE-DIM an array of Types, and those types contain entities, then you've lost those entities as well. Example: Type Cube Field Cub End Type Dim C.cube(10) For z=0 To 10 C(z)\cub = CreateCube() Next Dim C(12) ;; -- at this point you've lost everything, congratulations ![]() ;-------------------------------------------------------------------------- Speaking of cubes and cube types, if you enjoy adding obfuscation to your code, to drive people mad of course, then do stuff like this: Type cube Field cube.cube Field c End Type cube.cube = New cube For z=1 To 10 ;; a recursive depth of cubes and cubes? cube\cube = New cube cube\cube\c = createcube() cube = cube\cube Next ;; --- then the 'dedicated function' to free up that Type will be very interesting ... ![]() http://en.wikipedia.org/wiki/Obfuscation |
| ||
I thought that maybe there would be a way to retrieve entities if they were named using the EntityName function, but apparently that is a dead-end too, and won't work. { an old post by markcw describes a way to link Types with Entities. } http://www.blitzbasic.com/Community/posts.php?topic=75556 |