bitmap scrollRect rounding values when scaling on iPad
I have a project that was designed for iphone. I have been told to make it work "full screen" on the ipad.
Most of the backgrounds and art resources have been changed to be 960x720 so that when it scales up on the ipad, it will scale evenly to 1024x768. I do not have any say in this, I have to work with that.
The stage is still set to 960x640 with the scale mode being "show all"
The stage quality is set to low because of memory concerns. Setting it to anything causes crashes on older devices.
Now, for the most part, this works just fine. However, I am having a problem with some of the animated sprites.
So the "parent" container sprite is scaled up 1.0666666666666666666666666666667 (1024/960)
In my library, I have a spritesheet which is 2730x116 consisting of 21 frames.
On the screen, I create a sprite object, and then put a bitmap containing my sprite sheet in that sprite.
I then give the bitmap a scrollRect to only show the frame that I want to show. (these values are stored in an array that was created when I created the sheet)
Now, when scaling is 1:1 - everything is positioned and works just fine.
However, when I scale up to 1024x768, the scrollRect stops working as it's supposed.
What I have determined is that when it sets the scrollRect on the bitmap, it's not taking the stage scaling into account. I have verified this by invert scaling the bitmap by 960/1024 (bringing it back on an on-screen scale ratio of 1:1) - but now it's the wrong size - but the scroll rect is working. If it set the bitmaps scalex and y back to 1, the scrollRects x/y/width/height starts showing the the incorrect bitmap data, even though the numbers in the trace output are correct.
I figured if I could set the scrollRect values to compensate for the scaling, then it would show the correct region, however, if I try to set the scrollRect values to a floating number, it is automatically rounding them
For example.
Let's say I want to show in my sprite sheet located at (x=390, y=0, w=130, h=116) which is frame 4 in my sheet.
Screen = 10204x768
Stage: x=960,y=640
Stagequality = low
StageScaleMode = show all
MainSpriteObject.scalex and y = 1.0666666666666666666666666666667 = (1024/960)
Create new sprite.
create new bitmap.
Bitmapdata in bitmap to sprite sheet (w=2730,h=116)
Bitmap.scrollRect = new Rectangle(390,0,130,116)
the position is wrong (and when I animate through the frames by changing the scrollrect x value by 130 pixels per fame) the image "jumps around"
if I try doing THIS:
bitmap.scrollRect = new Rectangle(390.06666667, 0, 130.0666667, 116.066667); (numbers are not perfect, but they illistrate my problem);
trace(bitmap.scrollRect) outputs: (390,0,130,116) - it rounded the decimals!
I've tried scaling the bitmaps parent sprite up and down, but to no effect.
I'm very quickly running out of ideas and could use any help on this.
How can I get the scrollRect on the bitmaps to display properly when their parent containers are scaled, or how can I get the scrollRect to accept float values?
