Hyas :). Basically i know how to do a circular motion.But this time i want to make this motion oval.I tried to modify the sin and cos but then he just jumps to his orbit.The code looks like this:
private function setupCircle():void
{
var playerX:Number = G.pX + 9;
var playerY:Number = G.pY + 9;
var dx:Number = playerX - x;
var dy:Number = playerY - y;
radius = 0.5 * Math.sqrt(dx * dx + dy * dy);
angle = Math.atan2(dy, -dx);
centerCoord.x = 0.5 * (playerX + x);
centerCoord.y = 0.5 * (playerY + y);
angleStep = 0;
speed = (1.0 / (Math.PI * radius)) * 10;
//the direction he will go
speed *= -1;
//var rand:Number = Math.random();
//if (rand < 0.5) speed *= -1;
}
private function updateCircle():void
{
angleStep += speed;
//over here tried to modify sin and cos
x = centerCoord.x + Math.cos(angle + angleStep) * radius;
y = centerCoord.y - Math.sin(angle + angleStep) * radius;
//check if he arrived at destination
var remainDist:Number = FP.distance(x, y, saveCoord.x, saveCoord.y);
if (remainDist <= 2) {
whatDo = animation = "fly";
}
}
I don’t rly know how to make his motion oval but in the same time when he begin the motion to not teleport to his orbit.I mean the point he is on be4 he starts is like some pixels away from his orbit when he begins the oval motion.Also at circular motion the code is just fine. Do you guys have any ideas? thx.