Game Development Community

t2dStaticSprite and instability issues

by Harry Durnan · in Torque Game Builder · 08/06/2013 (6:25 pm) · 4 replies

Hi,

Looking for ideas on a very sporadic hanging/crashing issue that I've run into. I originally did my in-game menus as t2dTextObject(s) using the onMouseDown function to have them respond to the mouse. I recently replaced most of them with t2dStaticSprite(s) and am now running into problems where the game will occasionally hang on essentially deleting one menu and drawing another. I have found that scheduling out the draw after the delete seems to alleviate the problem, but not solve it completely.

The image files are all .png's... and I updated the libpng code, but that didn't help. Anyone have any ideas what the cause of this might be?

#1
08/06/2013 (11:26 pm)
Schedule the deletion to prevent them from being removed during the click callback.

%menuItem.schedule(100, "safeDelete");

You can set visible and enabled to false so that they disappear promptly, then they'll be deleted shortly after.
#2
08/07/2013 (5:20 am)
What Richard said.
#3
08/07/2013 (9:34 pm)
I'll give it a try, though it will be a ton of reworking stuff. I'm not sure why it's only an issue since I changed the objects to t2dStaticSprites. If it was deleting them while still processing wouldn't it crash for any object type?
#4
08/07/2013 (10:37 pm)
May have something to do with different default settings - active, enabled, something that puts the sprite into the update loop but not the text objects, but you'd probably have to step through it in a debugger to be sure....