2dtoolkit获取sprite像素大小的方法

获取sprite像素的方法

Vector2 GetPixelSize(tk2dSpriteDefinition def){
float w = def.untrimmedBoundsData[].x;
float h = def.untrimmedBoundsData[].y; // Calculate dimensions in pixel units
float pixelWidth = w / def.texelSize.x;
float pixelHeight = h / def.texelSize.y; Vector2 sizeVec = new Vector2(pixelWidth, pixelHeight);
return sizeVec;
}

其中的def参数只要转入spirte实例的CurrentSprite属性就可以了,slicedSprite同理

上一篇:python3中报错:TypeError: 'range' object doesn't support item deletion


下一篇:HTML命名规范