Home » » Detect touch event in Processing for Android

Detect touch event in Processing for Android

Written By MR HARI on Minggu, 02 Juni 2013 | 01.32

Last exercise demonstrate the basic "Hello World of Processing for Android". This exercise show to to detect touch event, by implement surfaceTouchEvent() method.

Detect touch event in Processing for Android


import android.view.MotionEvent;

boolean showEvent = false;
int evAction;
int evX, evY;

void setup()
{
size(displayWidth, displayHeight);
background(0);

stroke(255);
strokeWeight(3);
}

void draw()
{
if(showEvent){
text("Action: " + str(evAction), 10, 50);
ellipse(evX, evY, 10, 10);

showEvent = false;
}
}

public boolean surfaceTouchEvent(MotionEvent event)
{
evAction = event.getAction();
evX = mouseX;
evY = mouseY;
showEvent = true;

return super.surfaceTouchEvent(event);
}


Share this article :

0 komentar:

Posting Komentar

 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Android Center - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger