| 02-08-2004, 11:21 PM | #1 |
Okay, I understand that floating texts create a memory leak if you don't add in the destroy floating text trigger even if it disapears. If this is not so please let me know, and that will solve the problem rather easily. If it is true then read on. What I am trying to do is create floating text over a sold tower (yes another td) The only problem is that I don't want memory leaks. My trigger works fine if you only sell one tower every 1.5 game seconds, as it waits that long, then destroys the last created floating text. Only problem is when towers are sold groups at a time, when this happens only the last text is destroyed and the others continue to float untill they disapear. So, I found the jass to make it so the text will fade out faster so that it won't matter if it is destroyed or not, the only thing is: will the text be deleated after fade out or a certain time, or just remain in memory? If the destroy is needed manually, is there someway to do so when multiple texts are created in this way? Assigning to a variable might somehow work, but I can't seem to figure out how I could do that. If someone could either help me figure out how to do variables for this or come up with another way to get rid of the texts I would appreciate it. If not I guess I will just not have the floating text in there. Heres the current trigger, not the jass version. Code:
Events
Unit - A unit Finishes casting an ability
Conditions
(Ability being cast) Equal to Sell Tower
Actions
Unit - Kill (Triggering unit)
Player - Add (Point-value of (Triggering unit)) to (Owner of (Triggering unit)) Current gold
Floating Text - Create floating text that reads ((+ + (String((Point-value of (Triggering unit))))) + Gold) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (85.00%, 78.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
Wait 1.50 game-time seconds
Floating Text - Destroy (Last created floating text)And here is the jass function Exoteric created, I don't know jass so if this code will not leak, then say so and it fixes my problems. (Dont use this in your maps unless you look here first http://www.wc3campaigns.com/forums/s...threadid=45095) Code:
function SetFloatingText takes string floattext, unit target, integer zoffset, integer fontsize, real red, real green, real blue, integer velocity, integer angle, real starttime, real frametime, real starttrans, real endtrans, real numframes returns nothing
local texttag floatingtext
local real loopvariable
local real transframe
call CreateTextTagUnitBJ( floattext, target, zoffset, fontsize, red, green, blue, starttrans )
set floatingtext = GetLastCreatedTextTag()
call SetTextTagVelocityBJ( floatingtext, velocity, angle )
call PolledWait( starttime )
set transframe = ( ( endtrans - starttrans ) / numframes )
set loopvariable = starttrans
loop
exitwhen loopvariable >= endtrans
call SetTextTagColorBJ( floatingtext, red, green, blue, loopvariable )
call PolledWait( frametime )
set loopvariable = ( loopvariable + transframe )
endloop
call DestroyTextTagBJ( floatingtext )
endfunction |
| 02-08-2004, 11:31 PM | #2 |
Um, don't know about your problem (It IS true that floating text NEEDS to be destroyed to prevent mem leaks though, perhaps store your text in an array variable? Code:
To get this kind of "Code" boarder (which will save the spacing in your trigger, which is important) You need to use code tags (hit the # button) |
