Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


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

    if (Key.isDown(Key.UP))
    if (_rotation > 0)
    if (Key.isDown(Key.RIGHT))
    if (_rotation < 90)
    _rotation ++;

    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
    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:
    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


Copyright 1999 - 2012