A few basic questions..
by Jason Booth · in Torque Game Builder · 01/09/2006 (10:01 pm) · 3 replies
Started working with t2d tonight and ran into a few issues somewhat might be able to address for me:
1. I've tried using the .setpivotpoint function to change the pivot point on my sprite, but the sprite seems to only rotate around the center of the sprite regardless of the value's passed in. One version of the documentation seems to indicate that the .setpivotpoint function is only for particles, if thats so, do I have to manually calculate and adjust the offset myself? It would be nice to be able to just adjust the pivot point on the sprite itself.
2. I'm currently driving velocity and autorotate based on key presses in much the same way the basic tutorial shows. However, there is no auto-scale function (or size velocity, if you will) and I want to drive my scale in much the same way as the position and rotation are being driven. How can I bind a key press to continuously adjust the scale of an object (within bounds)?
3. Is there any way to have TGE break and display on errors instead of just logging them?
Any help is appreciated; thanks..
1. I've tried using the .setpivotpoint function to change the pivot point on my sprite, but the sprite seems to only rotate around the center of the sprite regardless of the value's passed in. One version of the documentation seems to indicate that the .setpivotpoint function is only for particles, if thats so, do I have to manually calculate and adjust the offset myself? It would be nice to be able to just adjust the pivot point on the sprite itself.
2. I'm currently driving velocity and autorotate based on key presses in much the same way the basic tutorial shows. However, there is no auto-scale function (or size velocity, if you will) and I want to drive my scale in much the same way as the position and rotation are being driven. How can I bind a key press to continuously adjust the scale of an object (within bounds)?
3. Is there any way to have TGE break and display on errors instead of just logging them?
Any help is appreciated; thanks..
About the author
#2
2. Actually, the rotation works fine; it's scaling I don't know how to handle. There is no autosize function like there is for rotation, and no setSizeVelocity function. Basically, I want to scale my object up in one axis while the user presses a key..
01/10/2006 (7:52 am)
1. Ah, makes sense, even though it's a little wierd you can't adjust the pivot point on a standard sprite.2. Actually, the rotation works fine; it's scaling I don't know how to handle. There is no autosize function like there is for rotation, and no setSizeVelocity function. Basically, I want to scale my object up in one axis while the user presses a key..
#3
Hong Jin
01/11/2006 (10:25 pm)
For your 3rd question, I recommend to visit www.sickheadgames.com, and see if their product "torsion" is fit for your needs.Hong Jin
Torque Owner Philip Mansfield
Default Studio Name
1. AFAIK the .setPivotPoint isn't in place yet. Moving the pivot point of an object requires a recalcuation of physics based on where the object is now rotating, and I think that's scheduled for a later release. You can fake it by adding a dummy object to your scene and mounting your sprite to the dummy object with the required offset. Then when you rotate the dummy sprite you will get the effect you're looking for. It just requires a slight shift in your game as the player is effectively controlling the invisible dummy object rather than the player sprite directly.
There was a thread/resource that demonstrated this using the image of a hammer and setting a dummy sprite so that the hammer rotated around the handle but I can't seem to find that thread for you.
2. Must be because it's early, but I'm not sure what you mean here. Do you want to slowly build up the rotation rate as the player holds the key down? If so, you could try something like this:
// turns clockwise function turnCW() { $plane.setAngularVelocity( $planeTurnRate ); $planeturn=true; planeTurnSched(); } // turns anti-clockwise function turnCCW() { $plane.setAngularVelocity( -$planeTurnRate ); $planeturn=true; planeTurnSched(); } // stop turning CW function planeTurnStopCW() { if ( $plane.getAngularVelocity() > 0 ) { $plane.setAngularVelocity( 0 ); $planeturn=false; } } // stop turning CCW function planeTurnStopCCW() { if ( $plane.getAngularVelocity() < 0 ) { $plane.setAngularVelocity( 0 ); $planeturn=false; } } // plane turn scheduler function planeTurnSched() { if($planeturn) { $plane.setLinearVelocityPolar(($plane.getRotation()+90),$planeSpeed); //Every 1/10 second apply thrust schedule(100, 0, "planeTurnSched"); } }This code is ripped from one of my early projects in which the plane moves from right to left and the keys just rotate the player around in a circle, and they have no control over their forward speed.
In your actionmap you call turnCW and turnCCW on key down, and the relevant stop function on key up.
Hopefully that's of some use or helps point you in the right direction.