当我在 actionscript 3 中调整按钮的大小时,在我的赋值示例中,hitbox 变为文本而不是正方形:
http://www.datafilehost.com/download-5ff20e2c.html
视频解释问题:http ://sdrv.ms/YcnjYV
这是代码:
import flash.events.MouseEvent;
trace("Stage(X,Y):" + stage.stageWidth + "X" + stage.stageHeight);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
clickMe.addEventListener(MouseEvent.CLICK, handleClicks);
function mousePosition(event:MouseEvent) {
if(clickMe.mouseX >= 0 && clickMe.mouseX <= clickMe.width && clickMe.mouseY >= 0 && clickMe.mouseY <= clickMe.height)
{
do
{
var newX = Math.floor(Math.random()*stage.stageWidth);
var newY = Math.floor(Math.random()*stage.stageHeight)
}while(newX >= stage.stageWidth - clickMe.width || newY >= stage.stageHeight - clickMe.height)
clickMe.x = newX;
clickMe.y = newY;
if(clickMe.width > 50)
{
clickMe.width=clickMe.width - 5;
clickMe.height = clickMe.width - 5;
}
}
}
function handleClicks(event:MouseEvent)
{
trace("Button Clicked!");
}
调整对象大小时,如何使 hitbox 保持不变?