Log in or register to post comments

Whole Touchsrceen as button

June 20, 2011 - 2:29am #1

Hi!
I want my whole touchscreen to be a button. It shouldn´t matter where tapping on it and then a sound should be played.
Can anybody explain me how to do?

Thanks, Stephan

Whole Touchsrceen as button

June 29, 2012 - 2:56pm #7

Hello,

I think I understand you now. You need to send a call from java to your C++ code. You can do this by declairing a C++ funtion to reset the counter and then loading it in your java class. There is an example of this in the ImageTargets.java code. In the declarations we define:

private native boolean activateFlash(boolean flash);

Then in onOptionsItemSelected(MenuItem) we call this native function with:

boolean result = activateFlash(mFlash);

in ImageTargets.cpp we define activateFlash. You can modify this code to do the reset of your variable in native.

Thank you,

-Peter

Whole Touchsrceen as button

June 29, 2012 - 12:09pm #6

Thanks for your answers.

Although your answers are right i think my question was not correct (or i didn't understand the answers Tongue Out). Sorry about that, I'll try to explain better what i want.

I'm using ImageTarget and i used a variable in ImageTargets.cpp (lets say it is varX) wich increases from 0.0 to 300.0.

I want this variable to return to (0.0) when i tap the screen. I wrote the code you mentioned in the java file but I need to find out what  code i have to write in ImageTargets.cpp so i can get the tap event and reset the varX...

I've tried to understand what to do from Dominoes sample but didn't have any success.

I' m a real noob  so excuse me if this is a stupid question....

Thanks
Orestis 

 

Whole Touchsrceen as button

June 29, 2012 - 11:55am #5

As Peter has stated, it's best to handle touch events which don't interact w/ the OpenGL context using the touch APIs for whichever native OS you're developing for. But if you do need to interact w/ objects that you are rendering, take a look at the Dominoes Sample. This demonstates how to locate  touches.

Whole Touchsrceen as button

June 29, 2012 - 9:28am #4

Hello Filthydog,

The code below is in native. Please see the Android developer documentation here for more information on handling UI events.

Thank you,

-Peter

Whole Touchsrceen as button

June 28, 2012 - 2:03pm #3

How can i use this tap event in native???

For example i would like when i tap the screen to reset a variable (for example when tapped varX=0;)

Re: Whole Touchsrceen as button

June 20, 2011 - 10:27am #2

This seems like more of an Android question than QCAR. However, when a user touches the screen android will pass the even information to you app if it subscribes to the event. Add this to your main java activity:

@Override
public boolean onTouchEvent(MotionEvent event)
{ 
//look up on internet how to play sound in android and put here!
return true;
}
Log in or register to post comments