Differences between "datablock" and "new"
by Edoardo · in Torque Game Builder · 06/14/2010 (5:35 am) · 3 replies
What is the difference in using :
datablock AudioProfile( PepperPickupSound ) //<---- USING DATABLOCK
{
filename = "~/data/audio/general/pepper_pickup.wav";
description = "SoundOnce";
preload = true;
};andnew AudioProfile( PepperPickupSound ) //<------ USING OPERATOR NEW
{
filename = "~/data/audio/general/pepper_pickup.wav";
description = "SoundOnce";
preload = true;
};About the author
The creator of HOOGA (available on Apple Store)
#2
I've implementend into engine this fix : www.torquepowered.com/community/forums/viewthread/96713
But if I use only datablocks the fix work correctly? can I delete datablocks to release buffer memory?
06/15/2010 (1:26 am)
Thanks William for your explanation...I've implementend into engine this fix : www.torquepowered.com/community/forums/viewthread/96713
But if I use only datablocks the fix work correctly? can I delete datablocks to release buffer memory?
#3
I have an idea for a quick test you can run. After you program has started. Type the following into the console:
06/15/2010 (8:04 am)
Scanning through the TorqueScript parser, I think you can still delete classes created with the datablock keyword.I have an idea for a quick test you can run. After you program has started. Type the following into the console:
echo( isObject( PepperPickupSound ) ); // should return 1 PepperPickupSound.delete(); echo( isObject( PepperPickupSound ) ); // should return 0
Associate William Lee Sims
Machine Code Games
If you use "new" and it gets executed twice, you will have two objects. And very likely, you'll have leaked a little bit of memory because nobody knows about the first instance anymore.
In this specific case, you've probably got your audio profile defined somewhere where it will only ever be executed once, so you are safe with new.