Search This Blog

12/28/09

Tutorial 4: Moving Object in a Circuler Path

I hope u got the rectanguler movement right. Now we are moving to the circular path that uses the simplest of trigonometry that we did in the tutorial n angles.
To start with as usual draw anything and convert to movieclip. Select the clip and attach the follwing actionscrpt.I'm going to explain it later.

onClipEvent (load) {
var radius = 100;
//setting radius
var speed = 5;
//setting speed
var xcenter = Stage.width/2;
//setting center of rotation
var ycenter = Stage.height/2;
var degree = 0;
//setting degree to start with
var radian;
}
onClipEvent (enterFrame) {
degree += speed;
radian = (degree/180)*Math.PI;
this._x = xcenter+Math.cos(radian)*radius;
this._y = ycenter-Math.sin(radian)*radius;
}



Test your movie. Your clip is rotating around the center of the stage at a radius of 100 with a speed of 5. We can always add something to it to improve and u can always try that.Wait for the tutorials to come.

No comments:

Post a Comment