Created
September 15, 2016 00:01
-
-
Save terryjsmith/5c3d2946eb3b6deee7cf4c5bff889fa6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float ScriptTime::m_delta = 0; | |
ScriptTime::ScriptTime() { | |
m_delta = 0; | |
} | |
ScriptTime::~ScriptTime() { | |
} | |
void ScriptTime::Initialize(v8::Isolate* isolate, v8::Local<v8::Context> context) { | |
StartTemplate(isolate); | |
SetGlobalName("Time"); | |
AddVariable("deltaTime", GetDelta); | |
EndTemplate(context); | |
} | |
v8::Local<v8::Value> ScriptTime::GetDelta(v8::Isolate* isolate) { | |
return(v8::Number::New(isolate, m_delta)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a global "Time" variable | |
*/ | |
class ScriptTime : public ScriptGlobal<ScriptTime> { | |
public: | |
ScriptTime(); | |
~ScriptTime(); | |
/** | |
* Initialize our variable in JS namespace | |
*/ | |
static void Initialize(v8::Isolate* isolate, v8::Local<v8::Context> context); | |
/** | |
* Set our time delta | |
*/ | |
static void SetDelta(float delta) { m_delta = delta; } | |
/** | |
* Accessor functions | |
*/ | |
static v8::Local<v8::Value> GetDelta(v8::Isolate* isolate); | |
protected: | |
static float m_delta; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment