Getting MouseDown on TopMost Object Only?
by Amjad Yahya · in Torque 2D Beginner · 06/21/2013 (6:51 am) · 4 replies
When 2 objects overlap and you click the mouse over them you get onMouseDown callbacks for both of them, I want to be able to handle the topmost object callback only. This was an issue back in TGB and it seems that it have not been addressed in T2D 2.0, I recall in TGB someone did post a very good solution to this issue that involves calling t2dSceneGraph::onUpdateSceneTick() callback. This call back does not exist anymore, so I wonder what is the alternative in T2D 2.0.
About the author
#2
06/21/2013 (10:45 am)
Thanks Jeff, you've been so helpful. Though, I still want to know if there is an alternative to t2dSceneGraph::onUpdateSceneTick() callback!
#3
Anyway, try:
Scene::OnSceneUpdate() - Each physics tick (1/60th sec)
Scene::OnSceneRender() - Each frame.
06/22/2013 (8:48 am)
The callbacks were renamed to be something more sensible and less obscure. Why not try looking at the source itself, it's pretty simple to search for stuff like "OnXXXXXX". The callbacks are issued with a command like "Con::execute....."Anyway, try:
Scene::OnSceneUpdate() - Each physics tick (1/60th sec)
Scene::OnSceneRender() - Each frame.
#4
It would be helpful if all callbacks get documented.
06/22/2013 (9:55 am)
Thanks Alien Cabbage, That's what I was looking for.It would be helpful if all callbacks get documented.
Torque 3D Owner JeffH
function updateSceneTick() { cancel($sceneTicker); if ($mouseDownEaten) { // do stuff because the mouse is set } $sceneTicker = schedule(10, 0, updateSceneTick); // update it every 10 milliseconds }Then just call that function once somewhere to activate it. You can stop the tick by just using:
Hope this helps :)