PDA

View Full Version : Strange input coordinates on Android



rzuf
11-08-2010, 08:43 PM
Hi again. :)
I wrote a simple app: stickman following user's touch. Everything works fine on windows, but on my Android device (allmighty Samsung i5700) touch coordinates from OnInput function are invalid.
http://img593.imageshack.us/img593/6382/kumusta.th.png (http://img593.imageshack.us/i/kumusta.png/)


Screen-related functions in App::Init looks like this:


SetLockedLandscape(true);
SetManualRotationMode(false);
SetupFakePrimaryScreenSize(320,480);


Thanks in advance. :)

Seth
11-08-2010, 11:13 PM
Woah, nice job on doing an Android compile before I finished the wiki docs on that part, rzuf.

I think you need to SetManualRotationMode(true), not false.

Also, make sure in the manifest has android:screenOrientation="landscape" in it.

If it's still wonky, try the RTSimpleApp example and see if the input works correctly. (It is landscape, scaling up the screen from 480X320 as well)

PS: I'm soon going to update the examples with some improvements in the android build process, I finally figured out a way to get rid of the code duplication for the shared .java code and put them in the shared dir.

Also added multi-touch and trackball support.

Seth
11-09-2010, 01:23 AM
Hmm, I went to test RTSimpleApp and noticed it was running in portrait on Android as well as the "Nexus One Landscape" windows screen setup. It was rotating when it didn't have to.

I commited a fix to svn, here is the correct init code for RTSimpleApp, this may work better for you too:

(keep in mind the SetupFakePrimaryScreenSize() stuff is only needed if you want to be able to assume the screen is 480X320 in your code, and have it stretch internally to whatever the device really is)


SetManualRotationMode(true);


if (GetEmulatedPlatformID() == PLATFORM_ID_ANDROID)
{
//if we do this, everything will be stretched/zoomed to fit the screen
SetupFakePrimaryScreenSize(480,320); //game will think its this size, and will be scaled up
SetLockedLandscape(false); //because it's set in the app manifest, we don't have to rotate ourselves

} else
{
//if we do this, everything will be stretched/zoomed to fit the screen
SetLockedLandscape(true); //we don't allow portrait mode for this game
SetupFakePrimaryScreenSize(320,480); //game will think its this size, and will be scaled up
}

rzuf
11-09-2010, 09:37 AM
nice job on doing an Android compile before I finished the wiki docs on that part
You left nice readme.txt file in android folder, so that wasn't really a problem. Copy and paste it into wiki and that will do. :)


I commited a fix to svn, here is the correct init code for RTSimpleApp, this may work better for you too
That helped! Thanks! :D


PS: I'm soon going to update the examples with some improvements in the android build process, I finally figured out a way to get rid of the code duplication for the shared .java code and put them in the shared dir.

Also added multi-touch and trackball support.
Awesome, you are doing great work, thank you. :D