In your game sample you are registering CGameMgr as single-reference type:
// Register the game manager as a singleton. The script will access it through the global property
r = engine->RegisterObjectType("CGameMgr", 0, asOBJ_REF | asOBJ_NOHANDLE); assert( r >= 0 );
Is it possible, to call methods of this object this way (like calling static methods):
CGameMgr.SomeMethod();
or CGameMgr::SomeMethod();?
I have a global math object that I use. Since you really don't care about the type in this case and only about what it's name is and what it does, you could register your global object as something like
r=e->RegisterObjectType( "G_CGameManager",0,asOBJ_REF );
// Behaviors omitted.
r=e->RegisterObjectMethod( "G_CGameManager","void BeginGame() const",asMETHOD(CGameManager,BeginGame),asCALL_THISCALL );
Then you can register an already allocated instance of your game manager like so.
That's correct. If you don't register the factory behaviour the script cannot instanciate the type. An by registering the type as NOHANDLE you tell the script engine that it shouldn't allow any extra handles to it either, thus only the references you supply to the object will be accessible.
It's not yet possible to call global functions (or static methods) as if they are in the name space of the class. Once I get to implement support for namespaces, this should be possible to support too.
You can trick AngelScript though, by registering the static method with CDECL_OBJLAST. AngelScript will pass the object pointer to the static method as the last argument, but as the calling convention is CDECL the function will simply ignore it. This would allow you to do something like this: