Advertisement

Component System

Started by May 28, 2012 05:44 AM
9 comments, last by WitchLord 12 years, 8 months ago

I have a quick question. I got the id to an construct behaviour. I then execute the construct function through the scriptcontext. Everything went throught fine. Now how do i get the address of the object that was called through the asBEHAVE_CONSTRUCT. I try calling GetReturnObject from the context that execute the code but i keep getting null back.


To create an object you would need to call the factory, not the constructor. The factory is responsible for allocating, initializing (via the call to the constructor), and then return the handle to the newly created object.

The factory functions are found with the asIObjectType::GetFactoryByDecl() method.

CreateScriptObject() works by calling the default factory, i.e. the one that doesn't take any arguments. If you want to use any of the factories that takes arguments you'll have to manually call it by setting up a context and then use that to execute the factory.

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