Hello,
I recently tried to code something on iOS using Xcode and Objective-C. I thought it would be nice if I could hook scripting with AS into my game, but I encounter a lot of problems, most of them come from mixing Obj-C and C++ (Angelscript). I managed to compile AS and even create script engine, but thats as far as I can go with my limited knowledge.
For example how this should be handled in Obj-C class that's some kind of ScriptManager (creating engine, handling pool and message callback):
[source lang="cpp"] r = engine->SetMessageCallback(asMETHOD(CScriptMgr, MessageCallback), this, asCALL_THISCALL); assert( r >= 0 );
[/source]
I have no idea how to pass Obj-C method to asMETHOD() macro. Can I even do this? If not, how should I "bridge" such things with AS C++ API?
Its even worse when it comes to registering Obj-C classes (NSString, GLKVector etc.) - I have no idea where to start.
Did anyone make a successful implementation of AS on iOS and has any example that would let me start with this? Because I couldn't find a clue regarding working with AS and Objective-C.
Thanks,
noizex
Angelscript with Objective-C
Where are we and when are we and who are we?
How many people in how many places at how many times?
AngelScript is successfully on iOS in several projects. Though I do not know the details of those projects I do believe they have been implemented with C++ rather than Objective-C.
Unfortunately my knowledge of Objective-C is very limited. Perhaps it would be easier to integrate AngelScript through a pure C interface? Note, the C interface is a bit outdated and would have to be updated to the latest version of AngelScript to work, but it should be quite easy to do so by following the existing work.
Unfortunately my knowledge of Objective-C is very limited. Perhaps it would be easier to integrate AngelScript through a pure C interface? Note, the C interface is a bit outdated and would have to be updated to the latest version of AngelScript to work, but it should be quite easy to do so by following the existing work.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
AngelScript is successfully on iOS in several projects. Though I do not know the details of those projects I do believe they have been implemented with C++ rather than Objective-C.
Unfortunately my knowledge of Objective-C is very limited. Perhaps it would be easier to integrate AngelScript through a pure C interface? Note, the C interface is a bit outdated and would have to be updated to the latest version of AngelScript to work, but it should be quite easy to do so by following the existing work.
Yeah, I suppose they're written in C++ because mixing C++ and Obj-C in a way that would be required for AS to work is beyond sanity for me. Some weird bridges just to pass a callback, so I don't even think about registering everything I need for scripting. Would either end up with tons of bridging functions and even then I'm not sure it will work okay. C could be easier actually, because it more lightweight and it seems it works better with Obj-C than C++ classes, but it will be probably a hard work filled with void* and emptiness ;)
I think I will just give up on this idea, I use Angelscript successfully for my C++ cross-platform project, so I wanted to try it in this little iOS project, but it seems that difficulty of implementing it with Obj-C outweights any benefits of scripting for such a simple game. I'll probably code game logic in a time that will take me to register some basic functionality with Obj-C++.
Where are we and when are we and who are we?
How many people in how many places at how many times?
After reading up a little on Objective-C and Objective-C++ I understand that it is not possible to bind Objective-C class methods directly with AngelScript. Even if it is possible to somehow take the address of an Objective-C class method the way Objective-C works is completely different from C++. In Objective-C communication between classes are done through messaging and not direct calls of the class methods as is done in C++.
However, as Objective-C++ can include C++ code in the same program it should be straightforward to write global proxy functions that bridge the AngelScript to Objective-C interface. If you're using Objective-C then you will have to use the C interface for AngelScript, as Objective-C don't understand C++ code.
Regards,
Andreas
However, as Objective-C++ can include C++ code in the same program it should be straightforward to write global proxy functions that bridge the AngelScript to Objective-C interface. If you're using Objective-C then you will have to use the C interface for AngelScript, as Objective-C don't understand C++ code.
Regards,
Andreas
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
Popular Topics
Advertisement