Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4599072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:29:19+00:00 2026-05-21T23:29:19+00:00

Ok, so in creating a game in my spare time, I’ve been completely stuck

  • 0

Ok, so in creating a game in my spare time, I’ve been completely stuck when trying to code around the following scenario:

I want to capture tap events (TouchEvent.ACTION_DOWN), and then in 500ms intervals, I want to check to see if the screen is still pressed, and repeat the same action, ad infinitum.

So, I started out with:

switch (myTouchHandler.getAction()) {
  case (TouchEvent.ACTION_DOWN):
  case (TouchEvent.ACTION_MOVE):
    if (inputIntervalTooSoon()) return true;
    //do the magic i intend to do....
 }

....

private boolean inputIntervalTooSoon() {
        final long now = System.currentTimeMillis();
        if ((now - lastTouchEventTime) < 500) return false;
        lastTouchEventTime = now;
        return true;

And this produces the effect that It will wait the 500ms, but it doesn’t begin to immediately detect if my finger is still down. It will pick it up again if I move my finger slightly, and then go back to dormant.

If I dont include the Interval function, my action just fires constantly. Any ideas in how to better implement this would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:29:20+00:00Added an answer on May 21, 2026 at 11:29 pm

    I could imagine a Timing thread that is started on a TouchEvent.ACTION_DOWN, which would be started and run inside a loop that sleeps for 500ms. After the sleep it would then be able to perform its check, which would do your custom processing as well as checking whether or not TouchEvent.ACTION_UP happened or not (which you would have to record in the EventHandler).

    Of course there is a bit of synchronization that would be required.

    Does this make sense?

    Something along the lines of this:

    boolean upHappened;
    
    switch (myTouchHandler.getAction()) {
      case (TouchEvent.ACTION_DOWN):
      upHappened = false;
      new Thread(new TimerRunnable()).start();
      case (TouchEvent.ACTION_UP):
      case (TouchEvent.ACTION_CANCEL):
      upHappened = true;
    }
    
    class TimerRunnable implements Runnable {
      public void run() {
        while(true) {
          Thread.sleep(500);
          if(upHappened) break;
          //custom processing
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a game where I want to determine the intersection of a
I'm creating a game in c++ and OpenGL and want an enemy to move
I m creating a game, in that i want to use some animation, but
So I am trying to learn SDL and creating a small game. When the
Im creating flash game that have the functionality to capture/record its gameplay that can
So, I'm creating a 2d top-down game in Java. I'm following instructions from Java
Im creating a game ... I want to add a counter as a clock
I'm creating a game in C++ (speaking of which, does the code I use
I am creating a game engine using Java and Mozilla Rhino, and I want
im creating a game that has multiple levels and the levels contain multiple textures

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.