获取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同理

05-02 02:41