function FoodPosition():void { food.x = int(Math.random() * rows) * 2 * radius + 2 * radius; food.y = int(Math.random() * cols) * 2 * radius + 2 * radius; if (food.x > 580 || food.y > 580 || food.x < 0 || food.y < 0) { food.visi... function FoodPosition():void
{
food.x = int(Math.random() * rows) * 2 * radius + 2 * radius;
food.y = int(Math.random() * cols) * 2 * radius + 2 * radius;
if (food.x > 580 || food.y > 580 || food.x < 0 || food.y < 0)
{
food.visible = false;
}
}
当元件的坐标超出舞台时,让其可见性为false,这样写发现总是没有效果
你没把元件的宽度很高度算进去。。。
if(food.x+food.width/2>580||food.y+food.height/2>580........