I think this is kinda a bug maybe not a bug but more just a problem that I ran in to.
Because I use pixel accuracy in the rube editor for images I want my images to match exactly the dimensions on the device. So of course I used the script that resizes images to their pixel height. However the function that gets image pixel height:
Code: Select all
image.getPixelHeight()
// or width
returns an int (as you would expect, can't have half pixels). However this doesn't work so well in calculations because you end up with floating point innaccuracy's, for example when the image width or height is an odd number. It then doesn't scale correctly. So maybe using an int and not a float return type for this function doesn't make so much sense. This is my quick fix, I cast it to a float before using it in the script.
Code: Select all
float PTM = 30.0f;
image[] imgs = si(); //selected images
for (uint i =0; i < imgs.length; i++)
{
float height = imgs[i].getPixelHeight();
imgs[i].setScale(height / PTM );
}
I also have several other image scripts such as align to origin and align images side by side or snap to left edge. These help greatly with level building in the editor. Especially if you're using tileable sprites for example. I use the same float cast method in those scripts too.
Just sharing
