Results 1 to 2 of 2

Thread: [CharacterControl] Character Movement

  1. #1

    [CharacterControl] Character Movement

    Hi Kirupa,

    Having a issue of the property '_rotation'

    Name:  Screen Shot 2012-04-21 at 4.41.12 PM.png
Views: 93
Size:  10.1 KB
    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.

  2. #2
    1,391
    posts
    Registered User
    rotations 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:
    Code:
    if( Key.isDown(Key.UP) && _rotation > -90 ) { _rotation--; }
    if( Key.isDown(Key.DOWN) && _rotation < 0 ) { _rotation++; }
    the way you have this structured the controls should rotate the knob between "up" and "right" according to you diagram

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012