I’ve been trying t create a Pendulum with FlashPunk, this is my code :
var pendX:Number = 0;
var pendY:Number = 0;
var pendRadius:Number = 600;
var pendArc:Number = 150/360;
var pendSpeed:Number = .004;
var pendCount:Number = 0;
in the update function :
pendCount += pendSpeed;
pendCount %= 1;
var point = pendulum (pendX, pendY, pendRadius, pendArc, pendCount);
_pendulumTrap.angle = Math.atan2(point.x, point.y) * (75 / Math.PI);
the pendulum function:
public function pendulum (centerX, centerY, radius, aoi, completionRatio){
var easedOneToNegOne = Math.cos(completionRatio*2*Math.PI);
var aoiRadians = aoi * 2 * Math.PI;
var currentRotation = (easedOneToNegOne * aoiRadians);
var x = centerX + Math.sin(currentRotation) * radius ;
var y = centerY + Math.cos(currentRotation) * radius ;
return {x:x, y:y};
}
what i’m trying to do now is to add collision to my pendulum, i generated the mask :
mask = new Pixelmask(PENDULUMTRAP_ART);
but is there a way to move the mask in a way that follow the pendulum ?