hi,
i am using the gesture api to detect an interaction in a rectangle, there are 9 interactive zones, and i want to detect when the user tap the correct zone (the correct zone changes every 500ms) and increase a counter. But the counter isnt responding to the taps, because the counter not always increments its value, but when i change the period to 650ms the counter works fine, i really needed to be 500ms:
This code creates the interactive zones (9 in total) with posX, posY, Width y Height of some rects previously defined
This code detects if the tapped rectangle is the correctCode:public void createInteractiveZones() { Rectangle current; //Fija el listener para registrar eventos para GestureCanvas GestureRegistrationManager.setListener(this, myListener); //accede al tile resaltado for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { current = tiles[i][j]; myGestureZone[i][j] = new GestureInteractiveZone(GestureInteractiveZone.GESTURE_TAP); myGestureZone[i][j].setRectangle(current.getPosX(), current.getPosY(), current.getRectWidth(), current.getRectHeight()); GestureRegistrationManager.register(this, myGestureZone[i][j]); } } }
I use a timer to change the zoneCode:public void gestureAction(Object container, GestureInteractiveZone gestureInteractiveZone, GestureEvent gestureEvent) { //Codigo para Gestionar los gesture events eventGen = (MainScreen) container; // Canvas Container iposX = gestureInteractiveZone.getX(); // iposY = gestureInteractiveZone.getY(); //currentRect = eventGen.tiles[posX][posY]; if (iposX == posX && iposY == posY) { eventGen.updateScore(); //Update the counter } }
Is anyone can help me, ill be very gratefulCode:public void changeZone() { tilesTimer = new Timer(); TimerTask tilesTask = new TimerTask() { public void run() { updateZone(); // repaint the screen, drawing a the new correct zone } }; tilesTimer.scheduleAtFixedRate(tilesTask, 0, period); // works fine with period 650, but with period 500, //doesnt always works }
Thank you

Reply With Quote

