06-07-2005, 16:54
|
|
|
חבר מתאריך: 21.06.05
הודעות: 53
|
|
מצאתי את הקוד הבא:
מצאתי מדריך רק שלא היה כתוב הסברים שם.. רק תצרו MC של מכונית ותוסיפו את הקוד..
הנה הקוד:
קוד:
onClipEvent(load)
{
speed =0 ;
}
onClipEvent (enterFrame) {
// make the car go forward
if (Key.isDown(Key.UP)) {
speed += 10;
}
// make the car go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 10;
}
// tells the car to slow down after the speed of 20
if (Math.abs(speed)>20) {
speed *= .7;
}
// you can change the rotation of the car to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 10;
}
// here is where the hittest is for the boundary
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
והוא עובד מעולה, אבל אני לא מבין את כל הקטע של המשתנה SPEED ואת הקטע של Math.sin - cos מישהו יכול בבקשה להסביר לי מה זה??
נערך לאחרונה ע"י majin_omri בתאריך 06-07-2005 בשעה 16:56.
|