Page 1 of 1

rotating player

PostPosted: Sun Apr 22, 2007 8:04 pm
by mr-game
how do u rotate the player on a key down event eg
if you press the right arrow key he starts to rotate right and same for left

PostPosted: Sun Apr 22, 2007 8:19 pm
by pixelpoop

PostPosted: Sun Apr 22, 2007 8:21 pm
by mr-game
yea well i read that before and i didnt get it at all so can anyone put it into words i cant undertsand

PostPosted: Sun Apr 22, 2007 10:05 pm
by Sgt. Sparky
make the pre-rotated images and have them all in one animation,
make sure it is rotating starting with the player pointing right,
make it rotate all around(right to left) to the right again. :)
and lets say you pressed the left key(repeate enabled): animpos += 1;
and for the key down event of right(also repeat enabled):animpos += 1;
and for the draw actor event use,
Code: Select all
if(animpos > nframes)animpos = 0;
if(animpos < 0)animpos = nframes;

:D

oh and dont..

PostPosted: Tue Apr 24, 2007 12:00 pm
by kyensoftware
Oh...and dont have a group of images (image1, image2, etc.) because it will glitch and flick to the middle frame and back all the time...make a 1 file gif with UnFREEZ (google is like a bible!!:wink: )
When u use UnFREEZ put the delay to 0cs, or else it looks like crap!

PostPosted: Tue Apr 24, 2007 4:20 pm
by Sgt. Sparky
I do not think that a delay time would make it look like poo. xD
that would require a few big changes! xD :lol:
I know what ya' mean. :)

PostPosted: Sat May 26, 2007 5:38 pm
by FiLLLe1
Sgt. Sparky wrote:make the pre-rotated images and have them all in one animation,
make sure it is rotating starting with the player pointing right,
make it rotate all around(right to left) to the right again. :)
and lets say you pressed the left key(repeate enabled): animpos += 1;
and for the key down event of right(also repeat enabled):animpos += 1;
and for the draw actor event use,
Code: Select all
if(animpos > nframes)animpos = 0;
if(animpos < 0)animpos = nframes;

:D


Hi! I've tried this to my game to, but not i'm not getting it to work :/ .
This is what i've done:
- I've made 36 animations of my actor.
- I choose the option "Mulitple files" in the add animation area. (I made one gif animated rotation file to and tested.)
- The actor starts with the rotate at the right, and goes around to the right again.

So when i press "key up" i used the script you posted above and then the script for key down. But I don't know if i've understod it all wrong cuz it doesent rotate correctly. When i press key down, it rotates down. When i press key up, it just stops.

Plz help :) // Fille

PostPosted: Sun May 27, 2007 1:43 am
by Sgt. Sparky
I forgot for the right key
animpos -= 1;
but you can just use change animation direction forward or change animation backwards. :D

PostPosted: Sun May 27, 2007 8:52 am
by FiLLLe1
ok thx for answer :D but i'm still not getting it to work. It's something i've done terribly wrong. Ok, without scripts, the animation is rotating. Should it do that? Now when i press up and down it rotates that way but if the animation has rotated 180 degrees and i press up the animation just jump 180 degrees back to start position. And it never stops rotating.

Srry for many questions i'm not good at all on GE ;)

//Fille

PostPosted: Sun May 27, 2007 10:12 am
by DilloDude
You first need to stop the animation. On the create actor event, add a ChangeAnimationDirection("Event Actor", STOPPED) event. To rotate clockwise, use the script: animpos ++; and to rotate counter-clockwise, use the script: animpos --;

PostPosted: Sun May 27, 2007 10:47 am
by FiLLLe1
thanx :D it works!

PostPosted: Tue May 29, 2007 3:59 pm
by Sgt. Sparky
Yay! :D
(you do not need animpos++ or animpos --, just do what he said and change the animation direction to stopped when it is created, and when you release the left arrow key or right change the animation direction to stopped(on key up) and with the left key pressed, forwards animation direction, right key = backwards animation direction. :D)