Hi,

I'm having a bit of a hard time figuring out how to wrap C++ classes
for use in v8. Basically I'm using v8 as a VM for scripting in a game
engine, and I want to be able to create and destroy entities using it.
The class for entities is called 'Entity'.

Ideally, I'd like to have code that looks something like this:

var ent = new Entity(200, 200);
ent.setTexture("gfx/test.png");
ent.show();
setTimeout(function(){ delete ent; }, 2000);

First off, is it even possible to construct wrapped C++ objects using
"new Entity()"? In the documentation I interpreted that you would need
to make a function that passes back a new wrapped class instance for
each entity you want to wrap. In this example I would need to make a
function "createEntity()" and have it pass back a newly wrapped C++
Entity instance (similar to how I would need to call createElement()
from javascript to create a DOM node in a browser). Maybe I
interpreted this incorrectly.

Secondly, how would I go about doing cleanup after 'ent' is garbage
collected (eg unloading textures, deleting the wrapped class, etc.)?

Thanks again.

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to