1. Download our Official Android App: Forums for Android!

Apps Simple Collision Detection

Discussion in 'Android Development' started by Kadafi, Feb 24, 2012.

  1. Kadafi

    Kadafi Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    11
    Joined:
    Feb 24, 2012

    Feb 24, 2012
    11
    0
    15
    Hi, i am making a game where I have 2 bitmaps as objects, i want to check if object 1 and object 2 collide

    e.g.

    obj1 (moves around on screen)




    obj2 (at bottom always)

    when obj1 touch the top of obj2, i want to move obj1 back up.

    could anyway please help me with this. I have looked online and found many examples but they are too complicated, and I am just a new developer, and just want a simple collision detection and nothing too fancy.

    thanks
     

    Advertisement

  2. powerpoint45

    powerpoint45 Member
    Rank:
    None
    Points:
    16
    Posts:
    58
    Joined:
    Dec 27, 2011

    Dec 27, 2011
    58
    5
    16
    You will need to make your own if statements,such as
    if (left>otherballleft){
    Die
    }

    Just tweek it till u got it
     
    Kadafi likes this.
  3. aciampal

    aciampal Newbie
    Rank:
    None
    Points:
    36
    Posts:
    22
    Joined:
    Feb 4, 2012

    Feb 4, 2012
    22
    3
    36
    Italy
    For a simple collision check you can use the "bounding box collision algorithm".

    You can find a lot of samples and code on the net to explain this.
    A simple procedure (and explanation) can be found, for example, at :

    Collision Detection
     
    Kadafi likes this.

Share This Page

Loading...