Where can I find a basic function guide for iTorque?
by Adam Emrick · in iTorque 2D · 10/06/2011 (5:21 am) · 13 replies
I'm probably missing something obvious but in the documentation supplied there are example projects like Aquarium and Rainy Day. In it we learn wonderful scripting tidbits like
%this.setLinearVelocityX(15);
My desperate question at this point is, where do i find information on this and other functions? I'm simply trying to find the appropriate function (for example) to call to move my object diagonally.
Any help would be much appreciated.
%this.setLinearVelocityX(15);
My desperate question at this point is, where do i find information on this and other functions? I'm simply trying to find the appropriate function (for example) to call to move my object diagonally.
Any help would be much appreciated.
About the author
Recent Threads
#2
I can't seem to find it at the provided link either.
What is the equivalent function of setLinearVelocityX but for angled movement?
Am I missing some concept that explains why a straight string search for setLinearVelocityX would turn up empty on the specified file?
Thank you so much for the reply!
10/06/2011 (7:17 am)
I opened t2dStaticSprite.cc and did a search for setLinearVelocityX, nothing found.I can't seem to find it at the provided link either.
What is the equivalent function of setLinearVelocityX but for angled movement?
Am I missing some concept that explains why a straight string search for setLinearVelocityX would turn up empty on the specified file?
Thank you so much for the reply!
#3
Yes. setLinearVelocityX is not in the specified file. ;)
You want to search in t2dSceneObject.cc instead, which is where this particular method resides.
For future reference, any time you want to search for a particular function, do Shift+Command+F on your Mac. That will search the entire code base of your active project.
Good luck!
10/06/2011 (7:27 am)
Quote:
Am I missing some concept that explains why a straight string search for setLinearVelocityX would turn up empty on the specified file?
Yes. setLinearVelocityX is not in the specified file. ;)
You want to search in t2dSceneObject.cc instead, which is where this particular method resides.
For future reference, any time you want to search for a particular function, do Shift+Command+F on your Mac. That will search the entire code base of your active project.
Good luck!
#4
10/06/2011 (7:36 am)
What would be the proper function to move the object at an angle, rather than linear?
#5
Within that same file, you will see ConsoleMethods that utilize both the 'x' and 'y' axis for translation.
Also, don't get confused about what linear means. You're still moving in a straight line with these methods, which is a linear translation.
Does this help?
10/06/2011 (7:41 am)
@Adam - Within that same file, you will see ConsoleMethods that utilize both the 'x' and 'y' axis for translation.
Also, don't get confused about what linear means. You're still moving in a straight line with these methods, which is a linear translation.
Does this help?
#6
Mix that with the linear velocity functions.
10/06/2011 (7:41 am)
@Adam - setAngularVelocityConsoleMethod(t2dSceneObject, setAngularVelocity, void, 3, 3, "(float velocity) - Sets Objects Angular Velocity.n"
"Auto rotation and angular velocity are two different values, though both of them affect the speed at which the object rotates. Auto rotation is not affected by any of the object's physics, whereas angular velocity is. If an auto rotation is set, it will be used instead of angular velocity.n"
"@param velocity The speed at which the object will rotate.n"
"@return No return Value.")Mix that with the linear velocity functions.
#7
10/06/2011 (7:51 am)
Awesome, thanks for help and patience.
#8
Thanks!
11/07/2011 (8:45 pm)
How would I move my object the direction of the rotation? I am able to rotate objects now, but they continue moving at their linear velocity in the previous direction.Thanks!
#9
Rotate only modifies the object (image), but does not affect the forces pushing against it.
I think you need something like:
The above code will change your linear velocity by calculating speed (taking the length of your velocity vector (speed)) and giving it a direction.
0 is straight up, 180 is straight down 90 is right, 180 is left.
11/07/2011 (9:26 pm)
I think you need some math to convert the rotation angle into new linear velocities.Rotate only modifies the object (image), but does not affect the forces pushing against it.
I think you need something like:
$player.setLinearVelocityPolar(%myRotationAngle, vectorLen($player.getLinearVelocity() ) );
The above code will change your linear velocity by calculating speed (taking the length of your velocity vector (speed)) and giving it a direction.
0 is straight up, 180 is straight down 90 is right, 180 is left.
#10
so, in my case it would be $player.dump(), or %this.dump() I have only tried this in xcode, but here is a sample of what you will see in the debugger:
Member Fields:
AlphaTestValue = "-1"
......
Methods:
addBehavior() - (BehaviorInstance bi) - Add a behavior to the object
@param bi The behavior instance to add@return (bool success) Whether or not the behavior was successfully added
addComponents() - %obj.addComponents( %compObjName, %compObjName2, ... );
Adds additional components to current list.
@param Up to 62 component names
.....
getAtRest() - () - Gets whether the Object is at Rest.
@return (bool atRest) Whether or not the object is at rest.
getAttachedToPath() - () - Gets the t2dPath that this object is attached to
...
11/07/2011 (9:32 pm)
@Adam, another good way to get a function / property list is to call .dump() on the object, and watch your log output.so, in my case it would be $player.dump(), or %this.dump() I have only tried this in xcode, but here is a sample of what you will see in the debugger:
Member Fields:
AlphaTestValue = "-1"
......
Methods:
addBehavior() - (BehaviorInstance bi) - Add a behavior to the object
@param bi The behavior instance to add@return (bool success) Whether or not the behavior was successfully added
addComponents() - %obj.addComponents( %compObjName, %compObjName2, ... );
Adds additional components to current list.
@param Up to 62 component names
.....
getAtRest() - () - Gets whether the Object is at Rest.
@return (bool atRest) Whether or not the object is at rest.
getAttachedToPath() - () - Gets the t2dPath that this object is attached to
...
#11
11/07/2011 (9:47 pm)
Thanks a bunch for these tips ray, they helped A LOT! Can we strike up a conversation sometime?(gmail messenger?) Regardless, thanks again.
#12
%this.setLinearVelocityX(0);
%this.rotateTo(-125, 100);
%this.setLinearVelocityPolar(125, 55);
It's curious though, I had to but the negative value on rotateTo in order to get it to match up properly with setLinearVelocityPolar. When I gave them both the same value, my image rotated the wrong way. I assume the negative angle value just subtracts 125 from the current angle? Or is a negative number an actual direction?
11/07/2011 (10:03 pm)
Ok so to do a proper turn I did:%this.setLinearVelocityX(0);
%this.rotateTo(-125, 100);
%this.setLinearVelocityPolar(125, 55);
It's curious though, I had to but the negative value on rotateTo in order to get it to match up properly with setLinearVelocityPolar. When I gave them both the same value, my image rotated the wrong way. I assume the negative angle value just subtracts 125 from the current angle? Or is a negative number an actual direction?
#13
90 degrees to the right is -270 degrees to the left....or vice versa
as for chat, garagegames has a channel on irc.maxgaming.net (channel is #garagegames)
If you are on a Mac, download Colloquy and put in the connection (irc.maxgaming.net) and the channel, and a nickname, and You'll be in. My display name is Ray.
11/07/2011 (10:30 pm)
I go through lots of trial and error. My trig and vector math isn't all that good, so I struggle with it a bit. I am pretty sure a negative angle is just an angle going the other way, like 45degrees and -45 degrees are both '45' degree angles, but when we specify negative or positive, we are basically telling it left or right.90 degrees to the right is -270 degrees to the left....or vice versa
as for chat, garagegames has a channel on irc.maxgaming.net (channel is #garagegames)
If you are on a Mac, download Colloquy and put in the connection (irc.maxgaming.net) and the channel, and a nickname, and You'll be in. My display name is Ray.
Employee Michael Perry
ZombieShortbus
1. Open the source file for the class you want to look at, such as t2dStaticSprite.cc. Then do a search in that file for the word ConsoleMethod. This will list all the member functions for that class, like setLinearVelocityX.
2. We've got a list of most commonly used objects and functions in the documentation, under the Reference section. It's a WIP.