Rotating
by Danny Mejia · in Torque Game Builder · 08/15/2006 (6:01 am) · 9 replies
Thanks. But I also need it to rotate 90 d each time that I clikc on it. I have try to u mSin(0.500) but that just set it back to 0 d. What would be the best way to do this.
About the author
#2
Is your code not working because you've typed it in wrong, or does your image not recognise that it's been clicked? Don't forget you should be using:
08/15/2006 (7:01 am)
If you want to use the rotateTo command, you use it like this:%myObject.rotateTo(%angle, %speed);
Is your code not working because you've typed it in wrong, or does your image not recognise that it's been clicked? Don't forget you should be using:
$myImageObject.setUseMouseEvents(true);so that it can recognise any mouse events that occur on it.
#3
Also you should use setRotation instead of just setting the rotation directly.
08/15/2006 (8:15 am)
@NirAlso you should use setRotation instead of just setting the rotation directly.
%myObject.setRotation(30);
#4
This may not work, but hopefully it will get you started in the right direction.
08/15/2006 (1:10 pm)
I'd think that if it starts at exactly 0 degres, then you could just put a line like this on a OnMouseDown callback. (Make sure to do what Apurva said)if(%myObject.getRotation() != 270)
%myObject.setRotation(%myObject.getRotation() + 90);
else
%myObject.setRotation(0);This may not work, but hopefully it will get you started in the right direction.
#5
08/15/2006 (5:13 pm)
Thinks it works.
#6
08/15/2006 (5:19 pm)
Or eliminate the if statement for%rotation = (%myObject.getRotation() + 90) % 360; %myObject.setRotation(%rotation);which will allow you to handle object starting at any angle (not just multiples of 90).
#7
08/16/2006 (5:37 am)
What does the "%" mean in the first line?
#8
For example: 540 % 360 = 180
http://tdn.garagegames.com/wiki/TorqueScript_Quick_Reference
08/16/2006 (6:12 am)
It's a modulo operator: gives the remainder of dividing the first value by the second.For example: 540 % 360 = 180
http://tdn.garagegames.com/wiki/TorqueScript_Quick_Reference
#9
08/17/2006 (11:45 am)
Thanks.
Torque Owner Nir Ziso
Default Studio Name