Game Development Community

Stacked Objects, Mouse Events and Deletion

by Justin Proffitt · in Torque Game Builder · 06/25/2012 (9:41 pm) · 1 replies

I noticed that when you have scene objects stacked on top of each other and they all use mouse events and in addition one of the objects in front deletes the others in its click callback, the game usually crashes upon click. I have traced this back to the section in t2dSceneWindow.cc beginning at line 2356 - The pointers don't get nulled when the other objects are deleted, so the check fails to stop it from trying to send the event.

About the author

I am a college student majoring in physics. As it so happens I like programming, a hobby which extends my profession in web design.


#1
07/03/2012 (10:03 am)
what should probably do is use Pickpoint rather then mouse down

http://tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneGraph#pickPoint.28.25x.2C_.25y.2C_.5B.25groupMask_.3D_MASK_ALL.5D.2C_.5B.25layerMask_.3D_MASK_ALL.5D.2C_.5B.25showInvisible_.3D_false.5D.2C_.5B.25excludeObject_.3D_NULL.5D.29

essentially pick point will return all objects that exist at a specific point (such as the one returned by scene window mouse down). first item in the list returned is the one "ontop". Simply then call the items "onMouseDown" event manually.