好的,所以我知道如何通过修改第 1 层操作脚本中的 this.x 和 this.y 变量来在实际的 .fla 文件中移动舞台。
但是在文档类-公共类 Starlight 扩展了 MovieClip 中,无论我尝试什么,它似乎都不起作用,我的研究将我引向了这个使用代码:
for( i = 0; i < stage.numChildren; i ++){
stage.getChildAt(i).x -= player.speedx * player.bounceSpeed;
stage.getChildAt(i).y -= player.speedy * player.bounceSpeed;
}
我确实意识到与实际移动舞台本身相比,它很笨拙且速度较慢。而且我不确定如果另一个移动的物体进入舞台会发生什么,因为从技术上讲,这段代码不自然地改变了舞台上所有东西的x,y。
任何帮助表示赞赏!干杯
编辑:试过这个 -
var stage2:Sprite = new Sprite();
stage2.x = stage.stageWidth / 2;
stage2.y = stage.stageHeight / 2;
stage2.width = 4000;
stage2.height = 4000;
addChild(stage2);
for (i = 1; i < 50; i ++)
{
var asteroid:Asteroid = new Asteroid();
asteroid.x = Math.round(Math.random() * stage.stageWidth * 4);
asteroid.y = Math.round(Math.random() * stage.stageHeight * 4);
stage2.addChild(asteroid);
collisionList.addItem(asteroid);
asteroids.push(asteroid);
}