Can't get ACTION_UP in onSceneTouchEvent

  ... in the unlikely case you discovered a bug, post it here.

Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Sun Jun 24, 2012 6:45 am

Hi,

I'm having some issues with the Scene Touch Listener. I only receive ACTION_DOWN events. I never get ACTION_UP or ACTION_MOVE events. What i did it wrong?. Please help me :cry:.

My code is :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         public boolean onSceneTouchEvent(final Scene pScene,
  3.                         final TouchEvent pSceneTouchEvent) {
  4.                 switch (pSceneTouchEvent.getAction()) {
  5.                 case TouchEvent.ACTION_DOWN:
  6.                         Log.d(TAG, "onSceneTouchEvent # ACTION_DOWN");
  7.                         break;
  8.                 case TouchEvent.ACTION_UP:
  9.                         Log.d(TAG, "onSceneTouchEvent # ACTION_UP");
  10.                         break;
  11.                 }
  12.                 return true;
  13.         }
  14.  
Parsed in 0.015 seconds, using GeSHi 1.0.8.4
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Tue Jun 26, 2012 5:44 pm

Additional information :

I down load example code form https://github.com/morlicando/Wallpaper ... gine-GLES2

and I modify the code to test the on onSceneTouchEvent.
After i modify it my code is :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class WallpaperActivity extends BaseLiveWallpaperService implements IOnSceneTouchListener, IAccelerationListener{
  2.         private static final String TAG = "WallpaperActivity";
  3.        
  4.         private int CAMERA_WIDTH = 480;
  5.         private int CAMERA_HEIGHT = 720;
  6.         private Camera manokamera ;
  7.         private Scene manoscena;
  8.         private ITextureRegion skyRegion;
  9.         private BitmapTextureAtlas skyAtlas;
  10.         private ITextureRegion cloudRegion;
  11.         private BitmapTextureAtlas cloudAtlas;
  12.         private ITextureRegion palmRegion;
  13.         private BitmapTextureAtlas palmAtlas;
  14.        
  15.         public EngineOptions onCreateEngineOptions() {
  16.                 Log.d(TAG, "onCreateEngineOptions # ENTER...");
  17.                 // TODO Auto-generated method stub
  18.                 manokamera = new Camera(0,0,CAMERA_WIDTH, CAMERA_HEIGHT);
  19.                 Log.d(TAG, "onCreateEngineOptions # EXIT...");
  20.                 return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), manokamera);
  21.                
  22.         }
  23.  
  24.         public void onCreateResources(
  25.                         OnCreateResourcesCallback pOnCreateResourcesCallback)
  26.                         throws Exception {
  27.                 Log.d(TAG, "onCreateResources # ENTER...");
  28.                 skyAtlas = new BitmapTextureAtlas(this.getTextureManager(), 240, 320);
  29.                 skyRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(skyAtlas,this.getAssets(), "gfx/background.png", 0, 0);
  30.                 skyAtlas.load();
  31.                 cloudAtlas = new BitmapTextureAtlas(this.getTextureManager(), 240, 320);
  32.                 cloudRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(cloudAtlas,this.getAssets(), "gfx/sky.png", 0, 0);
  33.                 cloudAtlas.load();
  34.                 palmAtlas = new BitmapTextureAtlas(this.getTextureManager(), 240, 320);
  35.                 palmRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(palmAtlas,this.getAssets(), "gfx/palm.png", 0, 0);
  36.                 palmAtlas.load();
  37.                
  38.                 this.enableAccelerationSensor(this);
  39.                
  40.                 pOnCreateResourcesCallback.onCreateResourcesFinished();
  41.                
  42.                 Log.d(TAG, "onCreateResources # EXIT...");
  43.                
  44.         }
  45.  
  46.         public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
  47.                         throws Exception {
  48.                 Log.d(TAG, "onCreateScene # ENTER...");
  49.                 manoscena = new Scene();
  50.                 final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 5);
  51.                 final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
  52.                 autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT ,this.skyRegion, vertexBufferObjectManager)));
  53.                 autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-5.0f, new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT,  this.cloudRegion, vertexBufferObjectManager)));
  54.                 autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0f, new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT,  this.palmRegion, vertexBufferObjectManager)));
  55.  
  56.                 manoscena.setBackground(autoParallaxBackground);
  57.                
  58.                 manoscena.setOnSceneTouchListener(this);
  59.                 manoscena.setTouchAreaBindingOnActionDownEnabled(true);
  60.                 manoscena.setOnSceneTouchListenerBindingOnActionDownEnabled(true);
  61.                
  62.                
  63.                 pOnCreateSceneCallback.onCreateSceneFinished(manoscena);
  64.                 Log.d(TAG, "onCreateScene # EXIT...");
  65.                
  66.         }
  67.  
  68.         public void onPopulateScene(Scene pScene,
  69.                         OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
  70.                 Log.d(TAG, "onPopulateScene # ENTER...");
  71.                 pOnPopulateSceneCallback.onPopulateSceneFinished();
  72.                 Log.d(TAG, "onPopulateScene # EXIT...");
  73.                
  74.         }
  75.     /** Called when the activity is first created. */
  76.  
  77.         @Override
  78.         public boolean onSceneTouchEvent(final Scene pScene,
  79.                         final TouchEvent pSceneTouchEvent) {
  80.                
  81.                         Log.d(TAG, "onSceneTouchEvent # getMotionEvent: "+pSceneTouchEvent.getMotionEvent());
  82.                
  83.                 switch (pSceneTouchEvent.getAction()) {
  84.                 case MotionEvent.ACTION_DOWN:
  85.                         Log.d(TAG, "onSceneTouchEvent # ACTION_DOWN");
  86.                         break;
  87.                 case MotionEvent.ACTION_UP:
  88.                         Log.d(TAG, "onSceneTouchEvent # ACTION_UP");
  89.                         break;
  90.                 }
  91.                 return true;
  92.         }
  93. }
  94.  
Parsed in 0.019 seconds, using GeSHi 1.0.8.4


Have any one can tell me what i did it wrong? Why i can't get action up?

Thank you.
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby ctlayon » Tue Jun 26, 2012 6:50 pm

I dislike switch statements but here's an example of a scene listener using if statements, I don't believe there is a bug in the onSceneListener but correct me if I'm wrong.

[EDIT]
see post below deleted this code
Last edited by ctlayon on Tue Jun 26, 2012 8:01 pm, edited 1 time in total.
ctlayon
 
Posts: 155
Joined: Thu Jun 14, 2012 9:41 pm
Location: Champaign, Illinois

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Tue Jun 26, 2012 7:19 pm

Thank you very much for reply. (^^)
I try with isActionUp and isActionDown already but it still have the same problem. It always get only ACTION_DOWN event (T_T).

My test code is :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         public boolean onSceneTouchEvent(final Scene pScene,
  3.                         final TouchEvent pSceneTouchEvent) {
  4.                
  5.                         Log.d(TAG, "onSceneTouchEvent # getMotionEvent: "+pSceneTouchEvent.getMotionEvent());
  6.                
  7.                 if(pSceneTouchEvent.isActionUp()) {
  8.                         Log.d(TAG, "onSceneTouchEvent # ACTION_UP");
  9.                 }
  10.                
  11.                 if(pSceneTouchEvent.isActionDown()) {
  12.                         Log.d(TAG, "onSceneTouchEvent # ACTION_DOWN");
  13.                 }
  14.        
  15.                 return true;
  16.         }
  17.  
Parsed in 0.012 seconds, using GeSHi 1.0.8.4
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby ctlayon » Tue Jun 26, 2012 7:58 pm

sorry i accidentily deleted a line this will work:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.ctlayon.pathtest;
  2.  
  3. import org.andengine.engine.camera.Camera;
  4. import org.andengine.engine.options.EngineOptions;
  5. import org.andengine.engine.options.ScreenOrientation;
  6. import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
  7. import org.andengine.entity.scene.IOnSceneTouchListener;
  8. import org.andengine.entity.scene.Scene;
  9. import org.andengine.entity.scene.background.Background;
  10. import org.andengine.entity.util.FPSLogger;
  11. import org.andengine.input.touch.TouchEvent;
  12. import org.andengine.ui.activity.SimpleBaseGameActivity;
  13. import android.util.Log;
  14.  
  15. /**
  16.  * (c) 2010 Nicolas Gramlich
  17.  * (c) 2011 Zynga
  18.  *
  19.  * @author Nicolas Gramlich
  20.  * @since 11:54:51 - 03.04.2010
  21.  */
  22. public class BaseActivity extends SimpleBaseGameActivity implements IOnSceneTouchListener{
  23.         // ===========================================================
  24.         // Constants
  25.         // ===========================================================
  26.  
  27.         private static final int CAMERA_WIDTH = 720;
  28.         private static final int CAMERA_HEIGHT = 480;
  29.  
  30.        
  31.  
  32.         @Override
  33.         public EngineOptions onCreateEngineOptions() {
  34.  
  35.                 final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  36.  
  37.                 return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
  38.         }
  39.  
  40.         @Override
  41.         public void onCreateResources() {
  42.  
  43.         }
  44.  
  45.         @Override
  46.         public Scene onCreateScene() {
  47.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  48.  
  49.                 final Scene scene = new Scene();
  50.                
  51.                 scene.setBackground(new Background(1f,1f,1f));
  52.                 scene.setOnSceneTouchListener(this); //forgot this
  53.                 return scene;
  54.         }
  55.  
  56.         @Override
  57.         public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
  58.                
  59.                        
  60.                 if(pSceneTouchEvent.isActionDown()) {
  61.                         Log.d("Scene Touch", "Action Down");
  62.                 }
  63.                 else if(pSceneTouchEvent.isActionMove()) {
  64.                         Log.d("Scene Touch", "Action Move");
  65.                 }
  66.                 else if(pSceneTouchEvent.isActionUp()) {
  67.                         Log.d("Scene Touch", "Action Up");
  68.                 }
  69.                
  70.                 return true;
  71.         }
  72. }
Parsed in 0.017 seconds, using GeSHi 1.0.8.4
ctlayon
 
Posts: 155
Joined: Thu Jun 14, 2012 9:41 pm
Location: Champaign, Illinois

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Wed Jun 27, 2012 4:11 pm

Thank you for suggestion.

I try it already but it still have the same probl. I get only ACTION_DOWN event.
I think it work with SimpleBaseGameActivity but when it use with BaseLiveWallpaperService it not work.
I don't known my assumption it wrong or not. Please tell me if i wrong.

If you have other solutions please let me known. :)
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Wed Jun 27, 2012 4:13 pm

kitaronew wrote:Thank you for suggestion.

I try it already but it still have the same probl. I get only ACTION_DOWN event.
I think it work with SimpleBaseGameActivity but when it use with BaseLiveWallpaperService it not work.
I don't known my assumption it wrong or not. Please tell me if i wrong.

If you have other solutions please let me known. :)
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby ctlayon » Wed Jun 27, 2012 4:34 pm

That's so weird that it wouldn't work for the BaseLiveWallPaper, I'm not familiar with that plugin so I don't know if I'll be able to help =[ sorry! If you figure it out I'd be interested to know though!
ctlayon
 
Posts: 155
Joined: Thu Jun 14, 2012 9:41 pm
Location: Champaign, Illinois

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby kitaronew » Wed Jun 27, 2012 7:38 pm

Thank you for help me very much Ctlayon :D. If i have a solution to figure it I will tell you :D
kitaronew
 
Posts: 10
Joined: Sun May 20, 2012 6:33 pm

Re: Can't get ACTION_UP in onSceneTouchEvent

Postby ysuzuki » Thu Oct 11, 2012 1:14 pm

i have a same problem too!
i'm also making a live wallpaper project.
i can only get ACTION_DOWN and it comes when i RELEASED my finger from the screen!
ysuzuki
 
Posts: 2
Joined: Fri Sep 21, 2012 11:16 am

Next

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest