Reputation: 151
I have a ball that will be kicked by the player, it is a movieclip and I want it to get smaller little by little as it gets away from the original spot, a AS3 tween perhaps? This is the code moving the ball:
speed=10;
var ease:int = 100;
var gravity:Number = 0.5;
function moveBall()
{
var targetX:Number = mouseX;
var targetY:Number = mouseY;
var angle = Math.atan2(targetY,targetX);
bola.x = mouseX + Math.cos(angle);
bola.y = mouseY + Math.sin(angle) ;
ballRotation = true;
stage.removeEventListener(MouseEvent.CLICK, kick);
Thanks a lot for your patience and help!
Upvotes: 0
Views: 223
Reputation: 11198
If you have tweenlite/tweenmax, you can get a pretty realistic ball getting kicked with this code:
import com.greensock.*;
import com.greensock.plugins.*;
import flash.events.MouseEvent;
TweenPlugin.activate([BezierPlugin]);
ball.addEventListener(MouseEvent.CLICK, kickBall);
function kickBall(e:MouseEvent):void
{
TweenMax.to(ball,2,{scaleX:0,scaleY:0,bezier:[{x:400, y:-250}, {x:315, y:200}]});
}
Obviously you can tweak those values as you please.
example: http://ronnieswietek.com/_random/ball.swf
Upvotes: 1