Sign in to follow this  
ikam

Initialize object at declaration

Recommended Posts

Hi

 

I'm new to angelscript and I can't do what I want.

 

I have a c++ struct :

 

struct float2
{
float x;
float y;
};

 

 

I register the object and property :

 

r = engine->RegisterObjectType("float2", sizeof(float2), asOBJ_VALUE | asOBJ_POD); assert( r >= 0 );
r = engine->RegisterObjectProperty("float2", "float x", asOFFSET(float2,x)); assert( r >= 0 );
r = engine->RegisterObjectProperty("float2", "float y", asOFFSET(float2,y)); assert( r >= 0 );

 

 

now in script I would like to declare a global variable of this struct with something like that, but it didn't work :

 

float2 myPoint = { 0.5f, 0.5f };   // initialize with lists didn't work

 

how I can init my var at declaration ? Do I need a constructor ?

 

thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this