Advertisement

Registering Abstract Classes

Started by April 28, 2010 06:35 AM
0 comments, last by WitchLord 14 years, 6 months ago
Hi, We are currently trying make AngelScript work with our engine and we get to the point were we couldn't advance anymore. I searched for an answer on this but it seems I'm not understanding something because haven't found a similar question. I have a class called Surface it is abstract (some member functions and some pure virtual functions) I want to use it in the scripts in this way (as I use it in my engine): Surface@ the_surface = Get_ResourceManager().Get_Surface("TheSurfaceID"); the_surface.Draw( 10 - the_surface.Get_Width()/2, 20 ); Being Draw a virtual method and Get_Width a member method. I'm not sure if the function needs to be wrapped with a proxy class so the virtual methods take place in the C++ side. class SurfaceProxy { Surface* ptr; public: void Draw(int x, int y) { ptr->Draw(x,y); } ... RegisterSurfaceProxyAsSurfaceForAngelScript(); In the documentation it says they can be virtual but I'm not sure if this apply to polymorphism. Is there any example doing something similar I can check? Thanks in advance :) [Edited by - Pogacha on April 28, 2010 6:54:45 AM]
AngelScript supports the registration of abstract classes to allow polymorphism. There is no need to use wrappers for this as the abstract methods would be registered as normal virtual class methods.

You may want to take a look at the pages Registering a reference type and Registering class hierarchies in the manual.



The only restriction on the class methods is that methods for classes that use virtual inheritance is not supported. If you do happen to use virtual inheritance (which is unlikely) you will have to use wrapper functions to register these methods.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement