Hey guys i am trying to make this work it works with out the function (or method as C# calls it) but it would require a lot of similar code copied and pasted over and over again how would i get this to work? (if im making any sense)
public void objCollision(object a, object b)
{
if (a.Bottom >= b.Top && a.Right >= b.Left && a.Left <= b.Right && a.Top <= b.Bottom)
{
MessageBox.Show("Collision Detected!");
}
}
i just want to be able to use objCollision(box1, box2); if that is possible...
thanks in advance!
Loading
Bechir BejaouiPosted Jan 30, 2009, 10:32 AM
Ok you create a class
public class Box
{
// put your code here to perform the Shape strucutre and behaviour "how it moves for example"
public void ObjectCollision(Box box)
{
//you put your code here to check whether this and box
//make chocs
if(this.Left ... box.Left && ....)
{
}
}
}
in the Main code
Box box1 = new Box();
Box box2 = new Box();
box2.ObjectCollision(Box1);