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 8161971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:36:39+00:00 2026-06-06T18:36:39+00:00

I already asked this question but at that time I tought that the refresh

  • 0

I already asked this question but at that time I tought that the refresh time between to onTouch Events is my problem Android onTouch refresh rate . But it isn’t. So again my problem:
I need a Sprite moving left/right/up while my finger is touching the display. So my onTouchEvent return true. But this works only if my finger swipes a bit or if the touchscreen drivers are so worse that it jitters so much what is detected as finger movement.
I tought of a solution with Threads. So I start a Thread which is moving the player, which is interrupted when the finger is lifted. But maybe there is a better way to do that?

@Override
public boolean onTouchEvent(MotionEvent me) {
    ...
if (me.getY() < getHeight() / 2) {
    return doAction(0);
} else if (me.getX() >= getWidth() / 2)
    return doAction(2);
else if (me.getX() < getWidth() / 2)
    return doAction(1);
//doAction returns TRUE
...

}

  • 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-06-06T18:36:40+00:00Added an answer on June 6, 2026 at 6:36 pm

    ok I managed it with Threads. Here is a part of doAction.

    if (event == MotionEvent.ACTION_DOWN) {
                movePlayer = new Thread() {
                    public void run() {
                        while (!this.isInterrupted()) {
                            if (main.player.x > 5
                                    && now.getLevel()[playerXsc][playerYsc] == Level.FLAG_SKY
                                    && now.getLevel()[playerXsc][playerY2sc] == Level.FLAG_SKY) {
                                main.player.x -= 4;
                            } else if (main.player.x <= 5 && now instanceof L9)
                                main.player.x = aspectX * 19;
                            try {
                                Thread.sleep(5);
                            } catch (InterruptedException e) { break; }
                        }
                    }
                };
                movePlayer.start();
            } else if (event == MotionEvent.ACTION_UP) {
                Log.e("ui", "mpt interrupt");
                movePlayer.interrupt();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Searching here I found that this question was already asked , but I think
It's possible that this question has already been asked, but I can't seem to
I have already asked this question on SuperUser but it was suggested there that
I guess this question that would have already been asked here. I searched but
I have asked this question today already but this time I want to know
Yes, I have already asked this question, but the problem is much more specific.
I'm sure that this question has already been asked, but I don't really see
I've already asked this question on several forums, but without any good explanation of
I am sorry I have already asked this question on Superuser, but nobody answers
I've seen this question asked already - but none of the answers really gelled

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.