- Bug Fix: Rendering stops too soon on the far left/right home screens
- New Feature: Pulsing lights on background building
- Update: Removed uses-feature:live_wallpaper from the manifest (please fix your bug, Motorola!)
I've got a bit of time to kill, so here's an explanation:
Running a forced-landscape application (The camera app, for example), then returning to the home screen, results in the camera being zoomed in too far.
When the OpenGL viewport is created, I'm handed a width and height by the operating system. I divide the height by the width to calculate the ratio, which I then use to make sure field of view is correct on the in-engine camera. Right after that I set a flag called IS_LANDSCAPE, which a few things here and there key off of (landscape requires less horizontal scrolling, for example, because the camera view is wider). The place I set IS_LANDSCAPE looked like this:
if( screenRatio > 1.0 )
IS_LANDSCAPE = true;
So what's the problem? Well, if you switch to a landscape desktop, IS_LANDSCAPE gets set to true. Then, if you switch back to portrait... well, nothing happens then, because those two lines of code don't ever try to set it to false, so it stays set to true. Yes, this was a totally stupid bug. This now looks like so, which sets the value at all times:
IS_LANDSCAPE = (screenRatio > 1.0);
On some phones the far left and right edges of the city image end about a tenth of the way from the edge of the screen.
This one was a little more interesting, though it wasn't complicated. Basically, the way home-screen switching works is that when you swipe from one to another, a function called onOffsetChanged gets called. It gets passed a 0-1 value. The idea is, if you're on your far-left home screen, it's 0, if you're on your far-right home screen it's 1, and in-between it's whatever percentage across that space you're at. Pretty simple.
What I do with this is set a value within my wallpaper renderer called desiredCameraPos. Every frame, the actual camera position attempts to drift towards desiredCameraPos with some acceleration, so you get smoothly interpolated movement no matter what the offset changes to.
The person who reported this bug was using stock android, a Nexus One. I've been testing on an HTC Incredible, which uses HTC's modified home screen. HTC's home screens already try to do smooth interpolated movement, so their background parallaxes with the foreground icons. On top of that, when you're on the far right home screen and try to swipe right again, the camera actually pushes a little further then springs back, like it's on a rubber band. What does this mean? It means that on an HTC Sense phone, the far left and right screens aren't 0 and 1, they're more like 0.05 and 0.95. This means that when I was testing, I didn't see a gap, because the camera never got all the way to the end of the possible range.
So anybody testing Live Wallpapers on a phone running HTC Sense: keep in mind that it doesn't go all the way to the end when scrolling, and make sure you test by forcing the value to 0 or 1 and make sure things still work okay.
The funny thing is, we did test this on a Motorola Droid, which runs stock Android, and didn't notice the problem there, either. Why? I'm guessing because the Droid has a 480x852 screen instead of 480x800, so its camera view ends up being a bit more tall and skinny. Probably just barely enough that you don't see the edge.
The funny thing is, we did test this on a Motorola Droid, which runs stock Android, and didn't notice the problem there, either. Why? I'm guessing because the Droid has a 480x852 screen instead of 480x800, so its camera view ends up being a bit more tall and skinny. Probably just barely enough that you don't see the edge.
No comments:
Post a Comment