-
Hi,
I'm new to Flash, but not to programming. I've had experience in C/C++ but I'm stuck on my first flash project.
Eventually I want to recreate the old game spectrum classic Juggernaught.....but first things first.
At the moment I have a simple movie clip, of a square that rotates when you click the left and right arrow keys. What i want it to do is to travel in the same direction it's pointing.
I don't really know where to start in Flash (version 5)
Heres the code i got so far:
onClipEvent ( load ) {
rotspeed=5
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._rotation+=rotSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._rotation-=rotSpeed;
}
}
Any help will be much appreciated.
-
Code:
onClipEvent (keyDown) {
if (Key.isDown(Key.LEFT)) {
//change the value of rotspeed to speed up the rate of turn
rotspeed -= 5;
} else if (Key.isDown(Key.RIGHT)) {
rotspeed += 5;
}
}
onClipEvent (enterFrame) {
//change the number at the end of this i.e 5 to speed up or decrease speed of forward trajectory
ychange = (math.cos((math.PI/180)*rotspeed))*5;
xchange = (math.sin((math.PI/180)*rotspeed))*5;
setProperty (this, _y, this._y - ychange);
setProperty (this, _x, this._x + xchange);
setProperty (this, _rotation, rotspeed);
}
:)
-
Thanks!