Note that there are some explanatory texts on larger screens.

plurals
  1. POInputProcessor of libgdx does not fire
    primarykey
    data
    text
    <p>I'm trying to get a simple libgdx project running on Android. Everything is fine, but my InputProcessor does not fire its events. I implemented everything according to this tutorial: <a href="http://code.google.com/p/libgdx-users/wiki/IntegratingAndroidNativeUiElements3TierProjectSetup#Code_Example" rel="nofollow">http://code.google.com/p/libgdx-users/wiki/IntegratingAndroidNativeUiElements3TierProjectSetup#Code_Example</a></p> <p>The first call of "showToast" works fine and is shown on my screen => The showToast-Method does work. Unfortunately, I can't fire any of the InputProcessor events. Even the debugger does not stop there, so they are definitely not called.</p> <p>Edit: Here is the complete code. I only omitted the Calculator Class, since it works fine and should not be of any conern here. If anyone disagrees with that I can always add it, of course.</p> <p><strong>Surface Class in libgdx main project (Main class so to say)</strong></p> <pre><code>public class Surface implements ApplicationListener { ActionResolver actionResolver; SpriteBatch spriteBatch; Texture texture; Calculator calculator; public Surface(ActionResolver actionResolver) { this.actionResolver = actionResolver; } @Override public void create() { spriteBatch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("ship.png")); calculator = new Calculator(texture); actionResolver.showToast("Tap screen to open Activity"); Gdx.input.setInputProcessor(new InputProcessor() { @Override public boolean touchDown(int x, int y, int pointer, int button) { actionResolver.showToast("touchDown"); actionResolver.showMyList(); return true; } // overriding all other interface-methods the same way }); } @Override public void render() { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); calculator.update(); spriteBatch.begin(); calculator.draw(spriteBatch); spriteBatch.end(); } // Overriding resize, pause, resume, dispose without functionality } </code></pre> <p><strong>ActionResolver interface in libgdx main project</strong></p> <pre><code>public interface ActionResolver { public void showMyList(); public void showToast(String toastMessage); } </code></pre> <p><strong>Implementation of the ActionResolver interface within my Android project</strong></p> <pre><code>public class ActionResolverImpl implements ActionResolver { Handler uiThread; Context appContext; public ActionResolverImpl(Context appContext) { uiThread = new Handler(); this.appContext = appContext; } @Override public void showMyList() { appContext.startActivity(new Intent(this.appContext, MyListActivity.class)); } @Override public void showToast(final String toastMessage) { uiThread.post(new Runnable() { @Override public void run() { Toast.makeText(appContext, toastMessage, Toast.LENGTH_SHORT).show(); } }); } } </code></pre> <p><strong>Android Activity for inizializing the Suface-Class</strong></p> <pre><code>public class AndroidActivity extends AndroidApplication { ActionResolverImpl actionResolver; @Override public void onCreate(android.os.Bundle savedInstanceState) { super.onCreate(savedInstanceState); actionResolver = new ActionResolverImpl(this); initialize(new Surface(actionResolver), false); } </code></pre> <p>}</p> <p>I also implemented the InputProcessor in my Surface-class, but this should not (and did not) make any difference. Any ideas, what I'm missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload