Jump to content
  • Advertisement
Sign in to follow this  

Interfaces? Java Style in c++?

This topic is 4452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Guys and Gals, I have been working on a small application with a Game class, that is full of GameCharacter objects. Each GameCharacter object will have a pointer to an ActionScript object (myActionScript). The ActionScript is used to define a simple AI for the character, for use like: /* assume GameCharacter has ActionScript *m_myActionScript; is an ActionScript pointer */ /* assume ActionScript::Act() is declared in ActionScript */ Game.gameCharacter1.m_myActionScript->Act(); Now, what I would like to do is to have ActionScript act as a Java-like interface, where I can have other classes that implement it, and then pass these implementing classes around as if they were ActionScript objects. As an example, lets say I had a ActionMonster class defined and it implemented the ActionScript class. I want the GameCharacter object's m_myActionScript member to point to the ActionMonster object, even though they differ in type. And then when Game.gameCharacter1.m_myActionScript->Act(); is used, the ActionMonster::Act() is really called. Is this possible? I would think it is, but I am not sure what would be the best way to approach it. I'd love some help thinking up ways to design this. Thanks, -sevans

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!