I am Developing a Game in which I have two object that are: 1> plane and 2>cloud . I something to happen when they collide.
I have tried the following 2 methods but they were nothing to help:- 1)
if((cloud.getY()==plane.getY())&&(cloud.getX()==plane.getX()))
{
plane.reset();
}
and 2)
if(((cloud.getY() + cloud.getBitmap().getHeight() / 2)==(plane.getY() + plane.getBitmap().getHeight() / 2))&&((cloud.getX() - cloud.getBitmap().getWidth() / 2)==(plane.getX() - plane.getBitmap().getWidth() / 2)))
{
plane.reset();
}
I have initialsed both the plane and cloud with bitmaps in separate classes and the getY() and getX() methods return their co-ordinates in int.
the plane object:- plane=new Plane(BitmapFactory.decodeResource(getResources(),R.drawable.plane), 250, 700);
the cloud object is also same
Someone please help.