Actionscript:以不同的速度移动的对象

时间:2014-05-04 10:17:31

标签: actionscript-3 flash addchild

我有一个容器,其中有几个对象添加了addchild,容器以0.7的速度向左移动。在某个时刻,它会重置,使其看起来像一个不断移动的屏幕。

我想在某个点向舞台添加另一个对象,以相同的速度向左移动,我就这样做了。

然而,当他们向左移动时,他们不会以相同的速度移动。由于某种原因,它们在特定点上越来越近,随机地改变它们的速度。

这是flash的已知问题吗?可能是因为我的对象非常大,有几个alpha层在这里和那里?

以下是相关代码:

//containers
var bushes:Sprite = new Sprite();
//timer for bushes to reset
var busher = 0;
//speed
var bushspeed = 0.7;
//adds the container
addChild(bushes);
bushes.x = 55;
bushes.y = 312;
var addBush1:parkBush = new parkBush;
bushes.addChild(addBush1);
addBush1.width = 98;
addBush1.height = 73;
var addBush2:parkBush = new parkBush;
bushes.addChild(addBush2);
addBush2.width = 98;
addBush2.height = 73;
addBush2.x += 220;
var addBush3:parkBush = new parkBush;
bushes.addChild(addBush3);
addBush3.width = 98;
addBush3.height = 73;
addBush3.x += 440;
var addBush4:parkBush = new parkBush;
bushes.addChild(addBush4);
addBush4.width = 98;
addBush4.height = 73;
addBush4.x += 660;
var addBush5:parkBush = new parkBush;
bushes.addChild(addBush5);
addBush5.width = 98;
addBush5.height = 73;
addBush5.x += 880;
var addBush6:parkBush = new parkBush;
bushes.addChild(addBush6);
addBush6.width = 98;
addBush6.height = 73;
addBush6.x += 1100;

stage.addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event){
busher = busher + bushspeed;
bushes.x -= bushspeed;
if (busher >= 221){
bushes.x = 55;
busher = 0;
}
//adding the object
if (timer == 200){
addChild(mau1);
mau1.x = bushes.x + 900;
mau1.y = bushes.y;
mau1.Mau1anim.gotoAndPlay(1);
}
mau1.x -= bushspeed;

0 个答案:

没有答案