PDA

View Full Version : The joys of Key.isDown


ArcaneMX
04-12-2005, 11:40 PM
Hello everyone,

I am developing an RPG style game, and so far, I'm just working on the movement of the charecter (called "char").

I have a movie clip of an object, here is what it needs to do;

if (Key.isDown(UP)) {
rotate on it's registration point to the position facing up
if (Key.isDown(DOWN)) {
rotate on it's registration point to the position facing down
if (Key.isDown(LEFT)) {
rotate on it's registration point to the position facing left
if (Key.isDown(RIGHT)) {
rotate on it's registration point to the position facing right

It must rotate from where it currently is (ex. It is facing left, you press right, and it turns 180 degrees)(ex. It is facing left, you press up, and it turns 90 degrees).

The best I can come up with is this;

if (Key.isDown(UP) && if (it is currently facing down)) {
_rotation +=(given ammount until it reaches 180);
if (Key.isDown(UP) && if (it is currently facing right)) {
_rotation +=(given ammount until it reaches -90)
if (Key.isDown(UP) && if (it is currently facing left)) {
_rotation +=(given ammount until it reaches 90);
if (Key.isDown(UP) && if (it is currently facing up)) {
_rotation = 0

And repeat this, changin the situation for down, left and right.
I simply can't find the right way to word it, so any suggestions or help would be appreciated. Thank you,

Laguana
04-12-2005, 11:47 PM
Do you mean turns over time? If you do, i'd make it set up an onEnterFrame which rotates the character until it's all good. If you just want the character to move instantly though, you can just set the rotation.

ArcaneMX
04-12-2005, 11:57 PM
Yes, I've tried instant rotation, but its too choppy for what I want.
Yes, I do want over time, at best, I'm hoping for an ease out type effect.

What I need is the missing script for the "ammount until it reaches 90" code. The best thing would be to re-word it so it works, because I know i've st it up wrong in the example.