Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a collision handler for a Java game engine. I made an interface called Collidable. I have a method called onCollision which takes the parameter of my Engine Game Object.

public void onCollision(engine.objects.Object obj) {

}

I want to know how I can redo this so that I can give individual instructions for each Collidable object's onCollision method for how to collide with a Wall object or an Enemy object without having to write another method that has the parameters Wall and Enemy so that my engine is flexible. How can I do this?

share|improve this question
add comment

1 Answer

You are about to begin your journey into Overloading, it's an essential part of the Polymorphism.

The first result from Google is just enough to give you an idea.

This topics are the basic topics for every Java programmer and in general for every programmer who wants to code in an OO way, i suggest to pick a good book that can teach you the basic stuff or a good online resource.

share|improve this answer
1  
Overloading and polymorphism have nothing to do with each other. I assume you meant overriding. :) –  Sean Middleditch Aug 15 '12 at 7:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.