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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:42:05+00:00 2026-05-31T19:42:05+00:00

In Android I use a SurfaceView to display a simple 2D game. The bitmaps

  • 0

In Android I use a SurfaceView to display a simple 2D game. The bitmaps (.png) with alpha (representing the game objects) are drawn on the canvas.

Now I would like to do a simple but accurate collision detection. Checking whether these bitmaps are overlapping is quite easy.

But how do I check for collisions when these bitmaps have transparent areas? My challenge is detecting whether two balls collide or not. They fill up the whole bitmap in width and height both but in all four edges, there are transparent areas of course as it’s a circle in a square.

What is the easiest way to detect collisions there only if the balls really collide, not their surrounding bitmap box?

Do I have to store coordinates of as many points on the ball’s outline as possible? Or can Android “ignore” the alpha-channel when checking for collisions?

  • 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-31T19:42:06+00:00Added an answer on May 31, 2026 at 7:42 pm

    If it is ball collision you can perform analitical collision detection – it will be much faster then per-pixel detection. You only need to have two centers of balls (x1,y1) and (x2,y2) and radius r1 for the first ball and r2 for second one. Now if distance between centers of ball is less or equal of sum of radius then the balls are colliding:

        colide = sqrt((x1-x2)^2+(y1-y2)^2)<=r1+r2
    

    but a little faster way is to compare square of this value:

       colide =  (x1-x2)^2+(y1-y2)^2<=(r1+r2)^2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an android game, I tried using the canvas.drawText() method to display
Is there any way in Android to use a GLSurfaceView to display the camera
i want to use Android spinner with following data. Spinner will display only text
I would like to use Android phones as a way to do some processing
Moving objects in a 2D game is very easy in an Android 2D game,
I have a game where I draw and move bitmaps over a SurfaceView. The
I use a surfaceview to draw a pie chart in Android. In order to
I am developing an Android game and I have my SurfaceView rendering the game
I'm working on an android game, and just recently made the step to SurfaceView
I would like to use Android-x86 2.2 as an emulator on my Windows 7.

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.