I’m making a basic wave movement pattern using Math.sin and I have the behavior of the movement working, but I cant seem to factor in a custom angle. Here’s what I’m doing:
http://teamimpulse9.com/CosSin.html
This is perfect and works how I want it to, however, instead of moving to the right I want it to move at an angle (from starting position to mouse).
Here’s my code:
var angleRadians:Number = (angle/180)*Math.PI;
//var angleOffset:Number = angleBetween(new Point(stage.mouseX,stage.mouseY),new Point(newPosition.x, newPosition.y));
newPosition.x += 1;
newPosition.y = Math.sin(angleRadians) * radius;
circle.graphics.beginFill(0xFF0000);
circle.graphics.drawCircle(newPosition.x ,newPosition.y,1);
angle += curviness;
if(radius > 0){
radius -=.1;
}
I thought simply adding the angle offset would work, but I cant wrap my head around what is going wrong.