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

  • Home
  • SEARCH
  • 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 6160731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:21:18+00:00 2026-05-23T21:21:18+00:00

I have been working on a game for a while, and I am working

  • 0

I have been working on a game for a while, and I am working on the controls right now, and I am hitting an issue with the Action_Move. My code is set up as shown below.

for(int i = 0; i < event.getPointerCount(); i++)
            {
                if(event.getPointerId(i) == 0 && primDown)
                {
                    x = (int) event.getX();
                    y = (int) event.getY();
                }
                else if(event.getPointerId(i) == 1 && secDown)
                {
                    x1 = (int) event.getX(1);
                    y1 = (int) event.getY(1);
                    if(dirPadRight.contains(x1, y1))
                    {
                        Log.w("game", "Right " + x1 +" " + y1);
                    }
                    if(dirPadLeft.contains(x1, y1))
                    {
                        Log.w("game", "Left " + x1 +" " + y1);
                    }
                }
            }

The primDown and secDown booleans are set up in the switch statement below:

int index = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
            int pointerId = event.getPointerId(index);

            switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_POINTER_DOWN:
                if(pointerId == 0)
                {
                    primDown = true;
                }
                else if(pointerId == 1)
                {
                    secDown = true;
                }
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP:
                if(pointerId == 0)
                {
                    x = 0;
                    y = 0;
                    primDown = false;
                }
                else if(pointerId == 1)
                {
                    x1 = 0;
                    y1 = 0;
                    secDown = false;
                }                      
                break;
            }

Basically, I am just having it refresh the x, y, x1, and y1 any time any action happens, so that I don’t have to deal with ACTION_MOVE in the switch statement, but when I try moving with the secondary pointer, it doesn’t change the event.getX(1) or event.getY(1). AS you can see, I put the log statements into the second pointer part of my for loop, and they go off whether I have both the primary pointer down and the secondary down, or if I had lifted the primary pointer and just the secondary is down, but it isn’t changing the x1 or y1, it keeps outputting the original points.

Does anyone have any idea why this isn’t working for me? It is weird that it knows a movement is happening, but it just isn’t changing the x and y’s, so I figured someone would know here. Let me know if you need any more code. Thanks in advance!

WWaldo

  • 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-23T21:21:18+00:00Added an answer on May 23, 2026 at 9:21 pm

    try like this

    if(pointerId == 0)
                    {
                        primDown = true;
                        secDown=false;
                    }
                    else if(pointerId == 1)
                    {
                        secDown = true;
                        primDown=false;
                    }
    

    This is difficult to say what causing your problem without seeing all the code.May be you are messing up with the boolean variable so that whenever a code should work it is not working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on some legacy C++ code that uses variable length structures
I have been working as a native C++ programmer for last few years. Now
Been developing a game for a while, and currently re working the GUI, or
I have been working on Android for a few months. Now i want to
I have a been working on a game for Android and debugging it on
I have been working on an Android game for the past 6 months or
I have been working on a game for iphone and have run into a
Yo everyone! I have been working on an Isometric Tile Game Engine in HTML5/Canvas
I have been working on making an application for editing game plugins for a
I have been working on a web services related project for about the last

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.