我正在尝试使用 Capabilities 类在屏幕上以精确的 (2.5" x 5") 绘制一个精确大小的精灵,而不管屏幕的分辨率如何,但是虽然我相信代码是正确的,但精灵的大小并不准确 -实际用尺子测量时。
function inchesToPixels(inches:Number):uint
{
return Math.round(Capabilities.screenDPI * inches);
}
var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0x000000, 0.5);
mySprite.graphics.drawRect(0, 0, inchesToPixels(2.5), inchesToPixels(5));
mySprite.graphics.endFill();
addChild(mySprite);