Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actual^DJ_Link^

Posted 16 July 2013 - 07:53 AM

Hi guys,

I'm sorry if this is a dumb question but I'm kind of new using AS.

 

So I have a class in C++ called Sprite with a method set_image(string, string)

 

I've registered them this way

//register class
engine->RegisterObjectType("Sprite", sizeof(Sprite), asOBJ_VALUE | asOBJ_POD);
// Register method
engine->RegisterObjectMethod("Sprite", "void set_image(const string sheet, const string image)", asMETHODPR(Sprite,set_image,(const string&, const string&),void), asCALL_THISCALL);


But now I can I use that in the script side?

 

I would assume something like 

Sprite@ sp = new Sprite(); // Not sure if @ or *, confusion here
sp->set_image("backgrounds","space"); // is it a -> or . for handles?

After reading some docs on Angescript I found out the @ for object handles, but still, how do I allocate a new Sprite to use in script? Do I need to create a static function that returns a handle in C++?

 

Once again thanks for reading this.


#1^DJ_Link^

Posted 16 July 2013 - 07:52 AM

Hi guys,

I'm sorry if this is a dumb question but I'm kind of new using AS.

 

So I have a class in C++ called Sprite with a method set_image(string, string)

 

I've registered them this way

//register class
engine->RegisterObjectType("Sprite", sizeof(Sprite), asOBJ_VALUE | asOBJ_POD);
// Register method
engine->RegisterObjectMethod("Sprite", "void set_image(const string sheet, const string image)", asMETHODPR(Sprite,set_image,(const string&, const string&),void), asCALL_THISCALL);


But now I can I use that in the script side?

 

I would assume something like 

Sprite* sp = new Sprite();
sp->set_image("backgrounds","space");

After reading some docs on Angescript I found out the @ for object handles, but still, how do I allocate a new Sprite to use in script? Do I need to create a static function that returns a handle in C++?

 

Once again thanks for reading this.


PARTNERS