简体   繁体   English

限制动态对象的可能定位?

[英]Limit possible positioning of dynamic objects?

I have a function to generate enemy ships (Movie clip) and have them 'fly' across the stage at different heights. 我有一个生成敌舰的功能(电影剪辑),并使它们以不同的高度“飞过”舞台。 The problem I have is I want to limit this so that there is a 600 x 75px space at the top of the stage that the enemy ships do not fly across so that I can display the score and timer without the ships flying across them (So they can be easily seen). 我的问题是我想限制此范围,以便在舞台顶部没有敌舰飞过的600 x 75px的空间,这样我就可以显示比分和计时器,而飞船不会飞越它们(所以他们很容易看到)。 My stage is 600 x 350px. 我的舞台是600 x 350px。 I am just wondering if this is the best way to do this? 我只是想知道这是否是最好的方法吗? The code for the function that generates the ships is below: 生成飞船功能的代码如下:

function EnemyShipSmall()
    {
        this.x = 800;
        this.y = Math.random() * 300;
        speed = Math.random()*5 + 5;
        addEventListener("enterFrame", enterFrame);
    }

Thanks. 谢谢。

Try this : 尝试这个 :

function EnemyShipSmall()
    {
        this.x = 800;
        this.y = Math.random() * 275 + 75;
        speed = Math.random()*5 + 5;
        addEventListener("enterFrame", enterFrame);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM