Results 1 to 2 of 2
-
April 21st, 2012, 07:27 AM #13Registered User
posts[CharacterControl] Character Movement
Hi Kirupa,
Having a issue of the property '_rotation'
How this '_rotation' property works? In my game, i want is , the character is rotated in to that direction once that key is pressed.
this is my code, this is nested in the enterframe event
======script==============
//Rotation
if (Key.isDown(Key.UP))
{
if (_rotation > 0)
{
_rotation--;
}
}
if (Key.isDown(Key.RIGHT))
{
if (_rotation < 90)
_rotation ++;
{
}
=========/script==========
The problem with this code is the character doesn't stop rotating once at the correct orientation.
anyone can help?
Isuru Kusumal Rajapakse.
-
April 24th, 2012, 03:01 PM #21,391Registered User
postsrotations in Flash are based with the orientation pointing right on the x axis, with a range from 0 to 180 CW and 0 to -180 CCW - all flash calculations will resolve to these ranges, which are also related to radian values of the unit circle and general trigonometry - although you can assign larger values, for instance 360, it will be resolved to 0 if you were to trace the current rotation of the Object - another example: 270 == -90
in your example, since you are rotating the object by fixed increments - you should simply be able to adjust your conditional values to what you need - as in:
the way you have this structured the controls should rotate the knob between "up" and "right" according to you diagramCode:if( Key.isDown(Key.UP) && _rotation > -90 ) { _rotation--; } if( Key.isDown(Key.DOWN) && _rotation < 0 ) { _rotation++; }

Reply With Quote


Bookmarks