Echoing sprite scope/level?
by Isaac Barbosa · in Torque Game Builder · 01/06/2007 (8:39 am) · 12 replies
Hey guys!
I'm having some problems with TGB and I believe that they are caused because of the depth/scope/level of the referenced sprites. So I want to was if there is a way to use echo to get the right place of the sprite in the stage. I hope to be clear because this is the only thing that is stopping me now :(
Regards!
I'm having some problems with TGB and I believe that they are caused because of the depth/scope/level of the referenced sprites. So I want to was if there is a way to use echo to get the right place of the sprite in the stage. I hope to be clear because this is the only thing that is stopping me now :(
Regards!
#2
01/06/2007 (9:06 am)
Something like getClass or getDepth?
#3
I forgot to use
Now my game is working! TGB reference is confusing and extense but extremely useful...
01/06/2007 (9:16 am)
Now I understand (I believe) %this is the reference always....I forgot to use
%this.setUseMouseEvents( true );
Now my game is working! TGB reference is confusing and extense but extremely useful...
#4
%this is only a reference to the current object when you are in a namespaced function and its argument list specifically lists %this as the first argument.
01/06/2007 (11:11 am)
Isaac, you can use the "garbage can" icon to delete your double posts.%this is only a reference to the current object when you are in a namespaced function and its argument list specifically lists %this as the first argument.
#5
Now I understand the "%this" scope..., is there a way to reference a respawnPoint in the stage from another sprite? (I'm very customized to _root from flash... ;) )
01/06/2007 (4:51 pm)
Thanks for the tip Ben :)Now I understand the "%this" scope..., is there a way to reference a respawnPoint in the stage from another sprite? (I'm very customized to _root from flash... ;) )
#6
From one of your previous questions, 3694 is the reference identifier of the scenegraph in that particular run of the sim.
01/07/2007 (1:21 am)
That depends on what your respawnPoint is and where you've stored your references to it. The answer I guess is "yes" as long as you've structured your data to be able to provide that information.From one of your previous questions, 3694 is the reference identifier of the scenegraph in that particular run of the sim.
#7
01/07/2007 (10:11 am)
Humm... I'm still confused with a lot of stuff in TGB. I guess I need time and practice. And a fresh brain!
#8
If you stare at the code long enough it finally sinks in, it did for me anyway...
01/07/2007 (3:14 pm)
You should take a look at the Whack-a-Mole Example. It uses a global simset to list all the respawnpoints as they are created. You can then access then from any object/function in your script.If you stare at the code long enough it finally sinks in, it did for me anyway...
#9
Thanks
In the example of the whack-a-mole... the respawnpoints are all created on start game function? I'm thinking this way, so I'm trying to state this code in another sprites:
what I'm missing? must I set a collision active for the respawnPoints? and following the example of the whack-a-mole: %mole is an independant object from %respawnPoint?
Thanks and sorry if I'm confused.
01/07/2007 (5:37 pm)
Dustin... I think the simset is the right way here. I will try this for some days until get it done :) Thanks
In the example of the whack-a-mole... the respawnpoints are all created on start game function? I'm thinking this way, so I'm trying to state this code in another sprites:
function mySprite::onCollision(bla bla bla)
{
if(%dsrObj.class $= respawnPoint) //because every spawnPoint class is respawnPoint isn't? so I can't understand why I can do a collision detection this way...
{
//actions
}
}what I'm missing? must I set a collision active for the respawnPoints? and following the example of the whack-a-mole: %mole is an independant object from %respawnPoint?
Thanks and sorry if I'm confused.
#10
Maybe if you could explain in more detail what you are wanting to do, someone could help a little more...
Is it that you just can't get collisions to work or are you trying to figure out which respawnpoint mySprite has collided with?
01/07/2007 (7:46 pm)
I'm not exactly sure what your trying to acccomplish.Maybe if you could explain in more detail what you are wanting to do, someone could help a little more...
Is it that you just can't get collisions to work or are you trying to figure out which respawnpoint mySprite has collided with?
#11
I'm trying to add a new sprite after a mole is out of the hole to fire something. I want that that new sprite travel through the scene checking if it collides with any respawnPoint it founds. Until now, I can do it now in a successful way. I can do it but the collisions with the %mole sprites stop functioning.
I notice that in the function MoleLevel::spawnMole(%this)... at the end, is this line:
and before we have this lines to make %mole collisionable:
That way a can reference the mole sprite to make a collision, but if after that I add
to make the respawnPoint collisionable the actual respawnPoint where a mole is spawned becomes collisionable and I can make it dissapear, but the other functions that has to do something with the %mole collisions becomes a mess. There is a conflict between the %mole and the %respawnPoint collisions. So I'm wondering if there is a chance to make both objects collisionable and how. Maybe the question is: is there a way to make respawnPoint collisionable without the need of set the collisions methods active inside the spawnMole function?
that's my problem and after four days I feel that I'm near but the feeling of that I'm lost don't let me see the answer.
Any help with this is greatly appreciated :) Thanks and sorry for the grammar.
01/08/2007 (8:08 am)
Dustin: I'm following the whack-a-mole tutorial and I'm beyond it now making a nice twist of it. I can manage collision between the mole sprites adding another sprites, but I can't for nothing doing a succesful collision between a sprite and an empty respawnpoint. I'm trying to add a new sprite after a mole is out of the hole to fire something. I want that that new sprite travel through the scene checking if it collides with any respawnPoint it founds. Until now, I can do it now in a successful way. I can do it but the collisions with the %mole sprites stop functioning.
I notice that in the function MoleLevel::spawnMole(%this)... at the end, is this line:
%mole.respawnPoint = %respawnPoint;
and before we have this lines to make %mole collisionable:
%mole.setCollisionActive( true, true ); %mole.setCollisionPhysics(false, false); %mole.setCollisionCallback(true);
That way a can reference the mole sprite to make a collision, but if after that I add
%respawnPoint.setCollisionActive( true, true ); %respawnPoint.setCollisionPhysics(false, false); %respawnPoint.setCollisionCallback(true);
to make the respawnPoint collisionable the actual respawnPoint where a mole is spawned becomes collisionable and I can make it dissapear, but the other functions that has to do something with the %mole collisions becomes a mess. There is a conflict between the %mole and the %respawnPoint collisions. So I'm wondering if there is a chance to make both objects collisionable and how. Maybe the question is: is there a way to make respawnPoint collisionable without the need of set the collisions methods active inside the spawnMole function?
that's my problem and after four days I feel that I'm near but the feeling of that I'm lost don't let me see the answer.
Any help with this is greatly appreciated :) Thanks and sorry for the grammar.
#12
01/08/2007 (8:26 am)
Maybe there is a way to make the respawnPoint collisionable here? in the respawnPointDatablock? function respawnPoint::onLevelLoaded(%this, %level)
{
%level.respawnPointSet.add(%this);
//code here?
}
Torque Owner Isaac Barbosa
IQ Games
over some sprites and I get 3694 in every case. what this 3694 means?
Thanks