Example Request Thread (if you need an example- request it! :)
by Matthew Langley · in Torque Game Builder · 04/14/2005 (11:40 am) · 31 replies
Ok... well here is a thread anyone can post a function or even a concept and request an example or a way to apply it... this way we can all share what we've already done and help eachother learn more :)
About the author
I Manage Tool Development for Torque at InstantAction
#22
As to the topic of this thread: I'm at the point where I want to start classing my objects with custom properties and events. I assume this is possible with TScript. If you've already done this tutorial, then sorry to be a pest. I looked and couldn't find anything. Also, is there an up-to-date "King Tut" page with every tutorial you've made? If not, there should be. I would bookmark that and check it daily. Thanks again!
04/19/2005 (5:57 am)
King Tut: I just want to say THANK YOU for all the tutorials, you are the man! Everything I've needed help with, you have a tutorial for. Very cool. If you are not on the GG payroll, you should be.As to the topic of this thread: I'm at the point where I want to start classing my objects with custom properties and events. I assume this is possible with TScript. If you've already done this tutorial, then sorry to be a pest. I looked and couldn't find anything. Also, is there an up-to-date "King Tut" page with every tutorial you've made? If not, there should be. I would bookmark that and check it daily. Thanks again!
#23
Do you have the variables $resX and $resY custom defined somewhere? When I plug your stuff in, it is blowing up because those variables are being returned blank...
Is there a preferences or global T2D variable that holds the screen resoultion (which is what I assume you're trying to get)?
04/19/2005 (1:03 pm)
LoTekk,Do you have the variables $resX and $resY custom defined somewhere? When I plug your stuff in, it is blowing up because those variables are being returned blank...
Is there a preferences or global T2D variable that holds the screen resoultion (which is what I assume you're trying to get)?
#24
However, I've decided that the cleaner solution is simply to have a line in each of the mouse callbacks (mousemove, mousedragged, etc)
Less fiddling about with unit conversion and all that jazz. :-p
04/19/2005 (2:38 pm)
Cruddy crud. Sorry 'bout that, I completely forgot about the two init lines at startup:$resX = getWord(getRes(), 0); $resY = getWord(getRes(), 1);
However, I've decided that the cleaner solution is simply to have a line in each of the mouse callbacks (mousemove, mousedragged, etc)
function sceneWindow2D::onMouseMove(%this, %mod, %worldpos, %clicks)
{
$mousePos = %worldpos;
}Less fiddling about with unit conversion and all that jazz. :-p
#25
I keep track of all my resources and other resources here
I also announce new additions there too :)
On the other topic that fading tutorial and moveTo tutorial show you how to extend an object th rough Torquescript... I'm working on a C++ tutorial for creating an in engine sub object of fxSceneObject2D, though I still have some work to do on that... that will show you how easy it is to extend the source and add your own custom objects...
@LoTekK: after fiddling I came to the same resolution lol :)
04/20/2005 (8:23 am)
@Kevin: thx for the compliments and if people learn something out of going through them then I have acheived my goal :) GG has already given me too much with these wonderful game engines they sell for practically nothing.I keep track of all my resources and other resources here
I also announce new additions there too :)
On the other topic that fading tutorial and moveTo tutorial show you how to extend an object th rough Torquescript... I'm working on a C++ tutorial for creating an in engine sub object of fxSceneObject2D, though I still have some work to do on that... that will show you how easy it is to extend the source and add your own custom objects...
@LoTekK: after fiddling I came to the same resolution lol :)
#26
I've been getting back into T2D recently, and was basically attempting to rewrite my turn-to/move-to code, and I realized that there are some cases where using onUpdateScene wil be preferable to using the onMouse callbacks.
Main thing I noticed, was that if your camera is moving a lot, using the onMouse callbacks isn't going to give you the desired response if you need something to be constantly pointing at or moving towards your mouse cursor. Why? Because the coords returned by those callbacks translate to word coordinates, rather than screen coords. Therefore, if the camera moves, but the mouse cursor doesn't, the coords being fed to the look-at/move-to function will no longer coincide with your mouse cursor. Instead, they'll coincide with the world coord your mouse was pointing to since you last moved the mouse.
08/25/2005 (1:34 pm)
Super bump!I've been getting back into T2D recently, and was basically attempting to rewrite my turn-to/move-to code, and I realized that there are some cases where using onUpdateScene wil be preferable to using the onMouse callbacks.
Main thing I noticed, was that if your camera is moving a lot, using the onMouse callbacks isn't going to give you the desired response if you need something to be constantly pointing at or moving towards your mouse cursor. Why? Because the coords returned by those callbacks translate to word coordinates, rather than screen coords. Therefore, if the camera moves, but the mouse cursor doesn't, the coords being fed to the look-at/move-to function will no longer coincide with your mouse cursor. Instead, they'll coincide with the world coord your mouse was pointing to since you last moved the mouse.
#27
Edit: Okay, it appears I have some clue as to what's wrong. Unfortunately, Pete111's program is not properly setting the coords for one of my objects I'm using to test the program with. The program keeps loading the image off-center. I have no idea why it'd do this... the polygons are there now, just in the wrong place.
08/25/2005 (6:59 pm)
I'd like to see a mini tutorial on how to script a custom collision poly (with Pete111's vertex plotter). The polygons I make never seem to work (they're convex, no worries). Whenever the edge of one sprite brushes against another sprite the collision occurs - instead of when the actual collision polygons collide.Edit: Okay, it appears I have some clue as to what's wrong. Unfortunately, Pete111's program is not properly setting the coords for one of my objects I'm using to test the program with. The program keeps loading the image off-center. I have no idea why it'd do this... the polygons are there now, just in the wrong place.
#28
08/26/2005 (8:22 am)
@LoTekk: The best solution would probably be to put something in the source in the integrateObject function (like my very basic C++ tutorial)
#29
08/26/2005 (1:36 pm)
Matt, you're probably right. For the time being though, it works nicely in script, and I'm much more familiar with TS (at least the T2D portion of TS) than C++, of which my knowledge is rather limited. Eventually, though, I'll probably start thinking about porting functions to the engine as I see the need. But that'll be much later. One of the things I love about T2D is just how much is doable in pure script, whether through in-built functions and classes, or through creative thinking. In due time I'll think about porting. :)
#30
08/26/2005 (1:38 pm)
I agree... its pretty amazing how much you really can get done in just script :)
#31
09/16/2005 (9:15 am)
Umm. All this trouble with fishing about for ways to convert screen space to world space, and there was a built in console method all along. Found it after I realized there was a very slight discrepancy with the conversion due to the menu bar on top of the window. So I was looking through the source to see if I could find anything useful in order to add some functionality, and what did I come across? Nothing less than sceneWindow2D::getMousePosition. I could kick myself.
Torque Owner Barry "Yossarian" Whitley
First off, I was just echoing the $dAngle to get an idea of the values it is throwing back, and they all end up being either 135 or -135... regardless of where I've positioned the mouse. Any ideas why that might be?
Also, small error on your last line.. should be:
$dLen = vectorLength2D($dDist); // returns a length
Otherwise is spews out errors.