我試圖讓我的代碼在我的頭像(你用手指移動的東西)移動時,因爲當你把手指放在它上面時,但是當你把它拿開回到頭像會立即傳送到我的手指,我希望他移動到它。請告訴我什麼,我做錯了什麼,我可以改進,使這項工作。(這是一類,這是爲什麼我使用公共)Tween對ActionScript 3的幫助
public var lastPosX:Number; public var lastPosY:Number;
public function onTouchBegin (e:TouchEvent):void {
var newPosX:Number = avatar.x; //the point of x your finger is
var newPosY:Number = avatar.y; //the point of y your finger is
//checks for first time putting finger down
if (isNaN(lastPosX)) {
avatar.x = e.stageX;
avatar.y = e.stageY;
//x and y values = to your finger
}
else {
var myTweenX:Tween = new Tween(avatar, "x", Strong.easeOut, lastPosX, newPosX, 5, true);
var myTweenY:Tween = new Tween(avatar, "y", Strong.easeOut, lastPosY, newPosY, 5, true);
//makes the avatar move to your finger when u lift your finger off and on
}
}
public function onTouchMove (e:TouchEvent):void {
avatar.x = e.stageX;
avatar.y = e.stageY;
//x and y values = to your finger
}
public function onTouchFinish (e:TouchEvent):void {
avatar.x = e.stageX;
avatar.y = e.stageY;
lastPosX = avatar.x;
lastPosY = avatar.y;
//x and y values = to your finger
//Defines x and y value of finger
}
您好,非常感謝您可以給我一個提示在代碼中做什麼導致,但我得到你的概念,謝謝(即時通訊非常新的閃光因爲我一直在編寫其他的東西,我只是在探索THA NKS:D) – EliteSkull