我有一个3个水平行的设置,其中每个按钮都对齐一个按钮,并且我想在这些行之间移动一个字符(居中显示为每行)小小大星球)。我能够对它进行编程,以便角色在3行之间移动,并在一定范围内进行设置,但我希望看到角色实际上在点之间移动;不只是看它传送到的位置。我试过了我能想到的所有东西:循环,布尔开/关,速度/距离/差异shenanigans等等,但是我没有成功让它在点击按钮时移动并继续移动,直到它到达它的位置点。我也不确定它是否可以设置为递增缩放,直到达到所需的末端缩放大小。我在网站上看到了一个类似的问题,但他们提供的解决方案使用了Point类和很多数学算法,并且我从未成功让我的Flash使用Points。任何建议,将不胜感激。在多个点之间平滑地移动和缩放一个MovieClip
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main_Test_5 extends MovieClip
{
private var cam:MovieClip = new MovieClip();
private var player:Player = new Player();
private var topPosition:uint = 170;
private var centerPosition:uint = 270;
private var bottomPosition:uint = 370;
private var UI:UserInterface = new UserInterface();
private var testBackground:TestBackground = new TestBackground();
public function Main_Test_5():void
{
player.x = 100;
player.y = 370;
cam.addChild(player);
addChild (UI);
// add event listeners
stage.addEventListener(Event.ENTER_FRAME, checkEveryFrame);
UI.topButton.addEventListener(MouseEvent.CLICK, topButtonClick);
UI.centerButton.addEventListener(MouseEvent.CLICK, centerButtonClick);
UI.bottomButton.addEventListener(MouseEvent.CLICK, bottomButtonClick);
addChild (cam);
}
public function checkEveryFrame(event:Event):void
{
cam.x -= player.x - player.x;
cam.y -= player.y - player.y;
}
public function topButtonClick (event:MouseEvent):void
{
trace ("Top Click");
if (player.y > topPosition) // 170, player.y starts at 370
{
player.y -= 100;
}
else if (player.y <= topPosition)
{
player.y = topPosition;
}
if (player.y == topPosition)
{
player.scaleY = 0.8;
player.scaleX = 0.8;
}
else if (player.y != topPosition)
{
player.scaleY = 0.9;
player.scaleX = 0.9;
}
}
public function centerButtonClick (event:MouseEvent):void
{
trace ("Center Click");
if (player.y > centerPosition) // 270
{
player.y -= 100;
}
if (player.y < centerPosition)
{
player.y += 100;
}
if (player.y == centerPosition)
{
player.scaleY = 0.9;
player.scaleX = 0.9;
}
}
public function bottomButtonClick (event:MouseEvent):void
{
trace ("Bottom Click");
if (player.y < bottomPosition) // 370
{
player.y += 100;
}
if (player.y >= bottomPosition)
{
player.y = bottomPosition;
}
if (player.y == bottomPosition)
{
player.scaleY = 1;
player.scaleX = 1;
}
else if (player.y != bottomPosition)
{
player.scaleY = 0.9;
player.scaleX = 0.9;
}
}
}
}
感谢大家的帮助。只要你们都提到了补间程序,我对补间做了一些研究,而且闪存有一个内置的补间系统,可以完美地满足我需要的功能。在玩了几天后,我解决了这个问题。 – crabdog62482