hushaojie04 / libgdx

Automatically exported from code.google.com/p/libgdx
0 stars 0 forks source link

Back key does not trigger key-down or key-up #1105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've just followed the drop tutorial as my first attempt at libGDX. - that was 
fine. (Using eclipse Indigo and nightly from about 4 days ago).
But when I attempt to intercept the back button (hard key on Android San 
Francisco 2) - nothing?
I've tried a couple of ways, currently I have added InputProcessor as follows:
public class Drop implements ApplicationListener, InputProcessor {...
...
public void create() {
Gdx.input.setInputProcessor(this);
Gdx.input.setCatchBackKey(true);
...
@Override
public boolean keyDown(int keycode) {
if (keycode == Keys.BACK) {
    dropSound.play();
    return true;
}
return false;
}
and the same for "keyUp".
But:
the app just ends when I press "back"
I have a breakpoint set on both if statements - they are not executed.
Don't know what SVN is, or "SVN trunk" - presume this relates to the latest 
stable version.
Not sure how I would update to the latest stable version: I tried running 
gdx-setup-ui.jar update for the drop project, and selecting the latest stable 
version of libGDX.
When I selected "open the update screen" I got the project (drop) in yellow 
undet "GWT modules" - don't know what this meant.
Then clicked launch.
Then tried to import into Eclipse and got "projects cannot be imported because 
they already exist"!
So guess I don't know how to update the version of libGDX.
Think I'll go back to basic Eclipse/Android.
and then importing the created drop project

Original issue reported on code.google.com by MBibby...@gmail.com on 28 Oct 2012 at 7:42

GoogleCodeExporter commented 9 years ago
Using the latest stable version refers to using the latest release, which you 
can find on the downloads page. Using the latest SVN trunk refers to using the 
nightlies, which you are already using. I should rework the issue template, 
thanks for pointing that out :)

On your problem: Your code looks, and testing something similar on my Galaxy 
Nexus running 4.1 results in the desired behaviour. It could be a device 
specific issue for the Android San Francisco 2. To rule that out, can you try 
your code in an emulator and see if it still doesn't work?

Original comment by badlogicgames on 2 Nov 2012 at 12:58

GoogleCodeExporter commented 9 years ago
If I run in the emulator i get gdxRuntimeException "Texture width & height must 
be powers of 2" - so I can't test the problem!
This seems bizarre: true my texture is 48*48, but I have useGL20 = true, and 
this bit works fine on my phone (Android 2.3.5). (I tried emulators for 2.3.3 
and 4.0.3 - both same result).

Original comment by MBibby...@gmail.com on 2 Nov 2012 at 6:59

GoogleCodeExporter commented 9 years ago
the emulator doesn't support GL 2.0

Original comment by badlogicgames on 2 Nov 2012 at 7:12

GoogleCodeExporter commented 9 years ago
OK, so I altered the textures to 64x64 and it worked fine in the emulator.
Tried it on the phone  and it also worked!
Reset to 48x48 and it still worked (on phone)!
I've been doing other things in Eclipse in the meantime so I don't know what 
cured the original problem!
C'est la vie say the old folks, it goes to show you never can tell!

Original comment by MBibby...@gmail.com on 2 Nov 2012 at 8:26

GoogleCodeExporter commented 9 years ago
Oki doki, glad you figured it out :)

Original comment by badlogicgames on 3 Nov 2012 at 11:51