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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:28:59+00:00 2026-05-25T00:28:59+00:00

When I use the method onTouch, I use the methon event.getY() to give the

  • 0

When I use the method onTouch, I use the methon event.getY() to give the variable y2 the finger precision. But one problem apper when I use a if-statement:

    public boolean onTouch(View v, MotionEvent event){
         if(y2 <= knifeY){
           //y2 = where the finger is, knifeY = where on the height a knife will be on.             
           knifeDown = false; 
           // The knife stops
           point--; 
           // score - 1;
           knife = BitmapFactory.decodeResource(getResources(),R.drawable.bloddyknife);
           // change picture.
           return true;
         }
    } 

But the problem is that you must move your finger when you hold it on the screen, if you’re holding it still, the knife just slip past. 🙁

Someone help?

  • 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-25T00:29:00+00:00Added an answer on May 25, 2026 at 12:29 am

    Do you assign int y2=event.getY() ? Because I dont see it anywhere, it must be done inside the onTouch()

    I’m not sure if this is good approach

    public boolean onTouch(View v, MotionEvent event)
    {
        while(event.getAction()!=MotionEvent.ACTION_CANCEL) // or here measure the pressure applied on the screen surface
        { 
           if(event.getY() <= knifeY)
           {
            knifeDOwn=false; // keep the knife down 
            point--; 
            knife = BitmapFactory.decodeResource(getResources(),R.drawable.bloddyknife); // 
             //maybe here you might stop the pointers collecting with using event.setAction(MotionEvent.ACTION_CANCEL) (or ACTION_UP) to exit the while loop, i dont know your idea for it, at this point i'm just guessing, but you still need to change the action of the event at anypoint at this code to exit the while loop.
           }
      }
      return true;
    }
    

    I suggest you to use GestureListener and use onFling() for this purpose.

    Read here more on constants of MotionEvent class:
    http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_DOWN

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

Sidebar

Related Questions

I have a screen filled with buttons, but want the onTouch-method to use the
I need to use method like: DoSomething<(T)>(); But i don't know which Type i
Does any one have a handy ready to use method to escape wildcards, invalid
As you know we can use method this.textblock1.focus() to get focus, but if I
In the first method listed below, the use method, it looks to me like
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I wish to use the method with the following signature: exec(String command, String[] envp,
actually i use this method to show similar words for a search request.. $query
What encryption method does the .NET FormsAuthentication.Encrypt() method use? There's no mention in the
is it possible to use a method of an abstract class? how can i

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.