I created a sprite and overrode onAreaTouched(). I want to make it so that when it's pressed, it does its action, but also, if they continue to hold down the button, the action continues. Here's my code:
Using java Syntax Highlighting
- Sprite downArrow = new Sprite(upDownArrowsX, downArrowY, this.mArrowTextureRegion, getVertexBufferObjectManager()){
- @Override
- public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
- mobile.setAngle(mobile.getAngle() - 1);
- return true;
- }
- };
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Trouble is, this only works if it is repeatedly tapped... well sort of. If I tap and hold in the same spot on the screen, it won't repeat. But if I "rub" the button for lack of a better word and give it more input points still within the touch area, the event will continue without me lifting my finger.
I checked the "ZoomExample" from the AndEngine examples... the one where if you touch and hold the screen zooms. The implementation is identical to mine, and shown below.
Using java Syntax Highlighting
- scene.setOnSceneTouchListener(new IOnSceneTouchListener() {
- @Override
- public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
- switch(pSceneTouchEvent.getAction()) {
- case TouchEvent.ACTION_DOWN:
- ZoomExample.this.mSmoothCamera.setZoomFactor(5.0f);
- break;
- case TouchEvent.ACTION_UP:
- ZoomExample.this.mSmoothCamera.setZoomFactor(1.0f);
- break;
- }
- return true;
- }
- });
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
I tried using this switch format and I didn't get any different results. In fact, doing that actually made it so that you couldn't even "rub it" at all. Had to actually lift the finger to get the action to occur again. My only thought is that this is the "onSceneTocuhEvent()" being overrode instead of the onAreaTouched(). Maybe something is different in the backend of the source code??
I'm pretty stumped on this one. Any help is appreciated.

