T2dSceneObjectGroup Updates
by David Higgins · in Torque Game Builder · 11/09/2006 (5:03 pm) · 5 replies
Any chance the t2dSceneObjectGroup object can contain all the methods that the t2dSceneObject contains AND recursively call the same functions on the underlying contained objects?
It seems the t2dSceneObjectGroup only covers a small set of the t2dSceneObject methods, and the t2dSceneObjectGroup isn't even documented -- I'm guessing it was created for LevelBuilder functionality and wasn't intended for game usage or something, since everyone seems to focus on the SimSet and SimGroup objects to group things together -- but it'd be nice to have a 'group' object that could contain a set of sprites or animations and have a single place to update them -- rather then having to write the code ourselves.
yeah yeah, i know, that was a "I'm lazy, do it for me" request :)
It seems the t2dSceneObjectGroup only covers a small set of the t2dSceneObject methods, and the t2dSceneObjectGroup isn't even documented -- I'm guessing it was created for LevelBuilder functionality and wasn't intended for game usage or something, since everyone seems to focus on the SimSet and SimGroup objects to group things together -- but it'd be nice to have a 'group' object that could contain a set of sprites or animations and have a single place to update them -- rather then having to write the code ourselves.
yeah yeah, i know, that was a "I'm lazy, do it for me" request :)
About the author
#2
For example, the group supports setPositionX and setPositionY but does not support setPosition, so created a setPosition function that calls setPosition on each of the child objects using;
I was thinking about making the changes to the C++ source, but then that would prevent me from distributing it to non-pro users -- so until a C++ solution is made, the TorqueScript solution will have to do for my purposes.
Thanks Thomas for the reply.
11/18/2006 (7:05 pm)
Well, I'm working on implementing a full set of t2dSceneObject methods within a t2dSceneObjectGroup so that the group object can be treated as if it is a single scene object and the action requested is performed on each scene object contained within the group;For example, the group supports setPositionX and setPositionY but does not support setPosition, so created a setPosition function that calls setPosition on each of the child objects using;
for(%x = 0; %x < %this.getCount(); %x++)
{
%this.getObject(%x).setPosition(%pos);
}I was thinking about making the changes to the C++ source, but then that would prevent me from distributing it to non-pro users -- so until a C++ solution is made, the TorqueScript solution will have to do for my purposes.
Thanks Thomas for the reply.
#3
This way all the objects will keep their positions relative to each other and you can move the entire group rather than moving all the objects to one point.
11/18/2006 (7:11 pm)
I think what you meant was this:function t2dSceneObjectGroup::setPosition(%this, %x, %y)
{
%this.setPositionX( %x );
%this.setPositionY( %y );
}This way all the objects will keep their positions relative to each other and you can move the entire group rather than moving all the objects to one point.
#4
This obviously assumes you have the previous setPosition function defined.
11/18/2006 (7:13 pm)
In keeping with the paradigm of vector functions, you could add a vector version too:function t2dSceneObjectGroup::setPosition(%this, %pos)
{
%this.setPosition( getWord( %pos, 0 ), getWord( %pos, 1 ) );
}This obviously assumes you have the previous setPosition function defined.
#5
Actually, my function is more or less as I wrote it above, although, I threw in some additional logic to the function for my particular needs.
I also have it written to accept a vector "x y" and not the x/y coords -- right now, the work I've done on it, is specific to the project I'm working on.
Depending on how quickly GG tends to the object in the C++ code, I'll probably make more useful changes to the C++ myself ... but for now, I want my code to be available to Trial, Indie and Pro users ...
But thanks for the quick response, as well as showing anyone else who may be reading the thread a faster way of doing the generic code -- as my code is not really generic, it uses the loop (I also don't expect more then 10 objects to be in the group at any point either).
11/18/2006 (7:30 pm)
Thomas, Actually, my function is more or less as I wrote it above, although, I threw in some additional logic to the function for my particular needs.
I also have it written to accept a vector "x y" and not the x/y coords -- right now, the work I've done on it, is specific to the project I'm working on.
Depending on how quickly GG tends to the object in the C++ code, I'll probably make more useful changes to the C++ myself ... but for now, I want my code to be available to Trial, Indie and Pro users ...
But thanks for the quick response, as well as showing anyone else who may be reading the thread a faster way of doing the generic code -- as my code is not really generic, it uses the loop (I also don't expect more then 10 objects to be in the group at any point either).
Torque Owner Thomas Buscaglia