Scene Event Manager
by Justin Proffitt · in Torque 2D Beginner · 03/12/2013 (12:30 am) · 0 replies
Hello everyone, long time no see. I am very excited to see a new fire in this engine and am amazed by the advances since I last visited. I saw that among many things the physics engine received a complete overhaul, which is making me giddy, but the GUI has received little love. Since we now have an awesome new engine and a far superior way of organizing all our assets, I figured more people are going to want make scene object based GUIs, and it'd be nice to have a way of tying logic to the scenes themselves. Enter my "Scene Event Manager", which adds a event queue to every scene so that you can schedule events in scene time. It's designed to work nearly identically to the schedule methods, and even has all the supporting methods (isEventPending, getEventTimeLeft, etc.). The advantage to using scene events over sim events is that scene events tick on scene time, which means they pause when the scene pauses and don't stack up, making them perfect for HUDs, choreographed events, count downs and the like.
It uses the method "sceneSchedule", and can be used either on scenes or scene objects in scenes, and it works exactly the same as schedule. Here example of all three uses:
It is based on the old torque engine, but I found it ported to T2D MIT smoothly. You can acquire a version of it from the "working" branch of my fork here
It makes changes to /game/defaultGame.cc, /sim/SimObject.cc, and /2d/scene/Scene.cc
Let me know if you have any questions. Enjoy! : )
It uses the method "sceneSchedule", and can be used either on scenes or scene objects in scenes, and it works exactly the same as schedule. Here example of all three uses:
// Scene.sceneSchedule(time, objID || 0, functionName, arg1, etc.) // (objID can be any object, not just a scene object) SandboxScene.sceneSchedule(1, 0, "echo", "Event!"); // Call "echo" as a global function after 1 second SandboxScene.sceneSchedule(1, enemy, "explode", "violently") // Call "explode" on enemy object after 1 second // SceneObject.sceneSchedule(time, methodName, arg1, etc.) Player.sceneSchedule(1, "setAnimation", "run") // Call "setAnimation" on player object after 1 second // (the event is queued in whichever scenegraph the player object resides in)
It is based on the old torque engine, but I found it ported to T2D MIT smoothly. You can acquire a version of it from the "working" branch of my fork here
It makes changes to /game/defaultGame.cc, /sim/SimObject.cc, and /2d/scene/Scene.cc
Let me know if you have any questions. Enjoy! : )
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.