本文整理汇总了C++中MEngine::getScriptContext方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getScriptContext方法的具体用法?C++ MEngine::getScriptContext怎么用?C++ MEngine::getScriptContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getScriptContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onBeginScene
void MGame::onBeginScene(void)
{
MEngine * engine = MEngine::getInstance();
// get level
MLevel * level = MEngine::getInstance()->getLevel();
if(! level)
return;
// get current scene
MScene * scene = level->getCurrentScene();
if(! scene)
return;
// update objects
scene->updateObjectsMatrices();
// start sound
scene->playLoopSounds();
// prepare physics
scene->preparePhysics();
// run script
if(engine->getScriptContext())
engine->getScriptContext()->runScript(scene->getScriptFilename());
}
示例2: ScriptAtlasSelect
int ScriptAtlasSelect()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
if(Atlas* atlas = (Atlas*)script->getPointer(0))
atlas->Select();
return 0;
}
示例3: MPluginEnd
void MPluginEnd(MScriptExt)
{
MResource::unregisterFactory("MScriptExt", MScriptExtGetter);
MEngine* engine = MEngine::getInstance();
if(engine->getScriptContext() == s_script)
engine->setScriptContext(NULL);
delete s_script;
}
示例4: ScriptAtlasWrite
int ScriptAtlasWrite()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
Atlas* atlas = (Atlas*)script->getPointer(0);
atlas->Save();
return 0;
}
示例5: update
void MGame::update(void)
{
MEngine * engine = MEngine::getInstance();
// run script
if(engine->getScriptContext())
engine->getScriptContext()->callFunction("onSceneUpdate");
// get level
MLevel * level = MEngine::getInstance()->getLevel();
if(! level)
return;
// get current scene
MScene * scene = level->getCurrentScene();
if(! scene)
return;
// update behaviors
unsigned int i;
unsigned int oSize = scene->getObjectsNumber();
for(i=0; i<oSize; i++)
{
MObject3d * object = scene->getObjectByIndex(i);
if(! object->isActive())
continue;
object->updateBehaviors();
}
// update scene
scene->update();
// update physics
scene->updatePhysics();
// update objects matrices
scene->updateObjectsMatrices();
// flush input
engine->getInputContext()->flush();
}
示例6: ScriptAtlasImageDestroy
int ScriptAtlasImageDestroy()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
MImage* image = (MImage*)script->getPointer(0);
if(image)
delete image;
return 0;
}
示例7: ScriptAtlasDestroy
int ScriptAtlasDestroy()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
Atlas* atlas = (Atlas*)script->getPointer(0);
if(atlas)
delete atlas;
return 0;
}
示例8: ScriptAtlasCreate
int ScriptAtlasCreate()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
unsigned int size = script->getInteger(0);
const char* name = script->getString(1);
script->pushPointer(new Atlas(size, 4, name));
return 1;
}
示例9: ScriptAtlasImageWrite
int ScriptAtlasImageWrite()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
MImage* image = (MImage*)script->getPointer(0);
const char* file = script->getString(1);
engine->getImageSaver()->loadData(file, image);
return 0;
}
示例10: begin
void MScene::begin(void)
{
MEngine * engine = MEngine::getInstance();
MScriptContext * scriptContext = engine->getScriptContext();
updateObjectsMatrices();
playLoopSounds();
preparePhysics();
// run script
if(scriptContext)
scriptContext->runScript(getScriptFilename());
}
示例11: ScriptAtlasImageGetSize
int ScriptAtlasImageGetSize()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
MImage* image = (MImage*)script->getPointer(0);
if(image)
{
script->pushInteger(image->getWidth());
script->pushInteger(image->getHeight());
return 2;
}
return 0;
}
示例12: ScriptAtlasGetSize
int ScriptAtlasGetSize()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
Atlas* atlas = (Atlas*)script->getPointer(0);
if(atlas)
{
MImage* image = atlas->GetImage();
script->pushInteger(image->getWidth());
script->pushInteger(image->getHeight());
return 2;
}
return 0;
}
示例13: ScriptAtlasGetUVs
int ScriptAtlasGetUVs()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
MVector2 uvs[2];
if(Atlas* atlas = (Atlas*)script->getPointer(0))
atlas->GetUVs(uvs, script->getString(1));
script->pushFloat(uvs[0].x);
script->pushFloat(uvs[0].y);
script->pushFloat(uvs[1].x);
script->pushFloat(uvs[1].y);
return 4;
}
示例14: ScriptSetColour
int ScriptSetColour()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
if(script->getArgsNumber() >= 3)
{
g_CurrentColour.r = script->getInteger(0);
g_CurrentColour.g = script->getInteger(1);
g_CurrentColour.b = script->getInteger(2);
if(script->getArgsNumber() >= 4)
g_CurrentColour.a = script->getInteger(3);
else
g_CurrentColour.a = 255;
}
}
示例15: MPluginStart
void MPluginStart(MScriptExt)
{
MResource::registerFactory("MScriptExt", MScriptExtGetter);
MEngine* engine = MEngine::getInstance();
s_script = new MScriptExtImpl;
// copy the existing environment
MScriptContext* oldScriptContext = engine->getScriptContext();
char fnName[256];
if(oldScriptContext)
for(int i = 0; i < oldScriptContext->getNumCFunctions(); ++i)
{
MScriptContext::CFunction fn = oldScriptContext->getCFunction(i, fnName);
s_script->addFunction(fnName, fn);
}
engine->setScriptContext(s_script);
s_script->init();
}