Bound Physical Object class to scripts

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-06-11 11:58:57 +05:30
parent 41a4619120
commit f3a41a2631
3 changed files with 7 additions and 0 deletions

View File

@ -11,5 +11,6 @@ void onTrigger()
//track_obj_manager.disable("hayBail.b3d");
TrackObject @t_obj = getTrackObject("hayBail.b3d");
t_obj.setEnable(false);
PhysicalObject @hay = t_obj.getPhysicalObject();
squashKart(0,35.0); //id of kart,time to squash
}

View File

@ -22,6 +22,7 @@
#include "script_track.hpp"
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
#include "tracks/track_object_manager.hpp"
#include "tracks/track_object.hpp"
#include "tracks/track.hpp"
#include <iostream> //debug
namespace Scripting
@ -81,6 +82,9 @@ namespace Scripting
r = engine->RegisterObjectType("TrackObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterGlobalFunction("TrackObject @getTrackObject(string &in)", asFUNCTION(getTrackObject), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterObjectMethod("TrackObject", "void setEnable(bool status)", asMETHOD(TrackObject, setEnable), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectType("PhysicalObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject @getPhysicalObject()", asMETHOD(TrackObject, getPhysicalObjectForScript), asCALL_THISCALL); assert(r >= 0);
//r = engine->RegisterObjectMethod("TrackObject", "const PhysicalObject @getPhysicalObject()", asMETHOD(TrackObject, getPhysicalObject), asCALL_THISCALL); assert(r >= 0);
}

View File

@ -126,6 +126,8 @@ public:
const PhysicalObject* getPhysicalObject() const { return m_physical_object; }
PhysicalObject* getPhysicalObject() { return m_physical_object; }
//Due to above overload AngelScript cannot decide which function to bind
PhysicalObject* getPhysicalObjectForScript() { return m_physical_object; }
const core::vector3df getInitXYZ() const { return m_init_xyz; }
const core::vector3df getInitRotation() const { return m_init_hpr; }