Scene Object help.
by 2dGamer · in Torque 2D Beginner · 02/10/2014 (12:50 pm) · 8 replies
Is it possible to put a bunch of objects in a SimSet?
Basicly, I want to have something like the "SphereStackToy" but instead of redrawing the whole scene (that's what it's doing as far as I can tell) just create a SimSet of "balls" and draw them and clear when done.
Basicly, I want to have something like the "SphereStackToy" but instead of redrawing the whole scene (that's what it's doing as far as I can tell) just create a SimSet of "balls" and draw them and clear when done.
About the author
#2
02/10/2014 (1:43 pm)
Or you can use the callOnChildren method to simplify step 3 and not have to iterate through everything. :-)
#3
02/10/2014 (1:49 pm)
I just love iterating, it's so sexy.
#4
I'm trying to easily clear objects from a scene without redrawing the whole scene...
02/10/2014 (3:12 pm)
I don't think you understand what I'm trying to do.I'm trying to easily clear objects from a scene without redrawing the whole scene...
#5
One thing that comes to mind is to add your objects to a scenegroup or a SceneLayer and then overriding the Scene rendering call in C++.
You could also create a second SceneWindow above your main scenewindow and create a scene with just the balls in it, assigning it to your top-most scene-window. You could then pause the scene in the main scenewindow and do whatever you want in the second scene/scenewindow.
Didn't try any of that but in theory, it *should* work.
If you can provide a more detailed example of what you're trying to achieve, maybe we can provide more precise assistance.
02/10/2014 (3:21 pm)
Hmm. That is going to be tricky to do since the scene is redrawn each frame.One thing that comes to mind is to add your objects to a scenegroup or a SceneLayer and then overriding the Scene rendering call in C++.
You could also create a second SceneWindow above your main scenewindow and create a scene with just the balls in it, assigning it to your top-most scene-window. You could then pause the scene in the main scenewindow and do whatever you want in the second scene/scenewindow.
Didn't try any of that but in theory, it *should* work.
If you can provide a more detailed example of what you're trying to achieve, maybe we can provide more precise assistance.
#6
02/10/2014 (4:14 pm)
Ok, start in source/gui/guiCanvas.cc in GuiCanvas::renderFrame(). From there you should easily be able to add or remove special scene rendering for your group.
#7
02/11/2014 (6:28 am)
I think what I'm going to do instead of this, is make like a block that moves and when it moves all the other objects fall and if the objects touch the ground they get destroyed. I'm not sure if this is possible.
#8
use objects' onCollision methods
and make sure their BodyType is set to "dynamic" and that they have valid collision shapes.
02/11/2014 (6:50 am)
Still don't understand what you are trying to do but yes, everything you've mentioned is possible.use objects' onCollision methods
and make sure their BodyType is set to "dynamic" and that they have valid collision shapes.
Associate Simon Love
1 - create the Simset
2 - add objects to your Simset
3 - When you need to, iterate through the simset and do what you need to do
for(%i = 0; %i<MySimSet.getCount(); %i++) { %obj = MySimSet.getObject(%i); %obj.function(); }