diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/common/je_lua_shared.hpp | 14 | ||||
-rw-r--r-- | src/lua/embed/scripts/boot.lua.h | 2 | ||||
-rw-r--r-- | src/lua/embed/scripts/graphics.lua.h | 6 | ||||
-rw-r--r-- | src/lua/modules/graphics/je_lua_bitmap.cpp | 4 | ||||
-rw-r--r-- | src/lua/modules/graphics/je_lua_graphics.cpp | 12 | ||||
-rw-r--r-- | src/lua/modules/graphics/je_lua_particle_system.cpp | 6 |
6 files changed, 27 insertions, 17 deletions
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp index ad65be0..bfe0629 100644 --- a/src/lua/common/je_lua_shared.hpp +++ b/src/lua/common/je_lua_shared.hpp @@ -10,25 +10,31 @@ namespace JinEngine namespace Lua { + class LuaObject; + /// /// Thread safe. /// class SharedBase { public: - void retain(); - - void release(); - bool isType(const char* t); const char* getType(); protected: + friend class LuaObject; + SharedBase(void* obj, const char* t); SharedBase(const SharedBase&); + // ͬһ̵߳lua_StateУLuaObjectEngineObjectӦһһӦLuaObject(lua runtime) + // üͻաEngine-sideüΪά̵ͬ߳lua_StateͬһEngineObject + void retain(); + + void release(); + virtual ~SharedBase(); void* mObject; diff --git a/src/lua/embed/scripts/boot.lua.h b/src/lua/embed/scripts/boot.lua.h index af81c16..a42f7d4 100644 --- a/src/lua/embed/scripts/boot.lua.h +++ b/src/lua/embed/scripts/boot.lua.h @@ -49,7 +49,7 @@ function jin.core.run() end step() dt = jin.time.getDelta() - call(jin.core.onUpdate) + call(jin.core.onUpdate, dt) jin.graphics.clear() call(jin.core.onDraw) jin.graphics.present() diff --git a/src/lua/embed/scripts/graphics.lua.h b/src/lua/embed/scripts/graphics.lua.h index e1079b9..1dddbf5 100644 --- a/src/lua/embed/scripts/graphics.lua.h +++ b/src/lua/embed/scripts/graphics.lua.h @@ -21,6 +21,12 @@ jg.SpriteOrigin = { BOTTOMRIGHT = 8 } +jg.SpriteMode = { + SINGLE = 1, + RANDOM = 2, + ANIMATED = 3 +} + local default_shader = nil local default_shader_source = [[ #VERTEX_SHADER diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp index 1733529..8d8b76e 100644 --- a/src/lua/modules/graphics/je_lua_bitmap.cpp +++ b/src/lua/modules/graphics/je_lua_bitmap.cpp @@ -23,8 +23,8 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - shared.release(); + LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); + luaObj->release(); return 0; } diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 981e30f..2fc8ecf 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -19,6 +19,7 @@ #include "je_lua_sprite.h" #include "je_lua_animation.h" #include "je_lua_animator.h" +#include "je_lua_particle_system.h" using namespace std; using namespace JinEngine; @@ -27,6 +28,7 @@ using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Fonts; using namespace JinEngine::Graphics::Shaders; using namespace JinEngine::Graphics::Animations; +using namespace JinEngine::Graphics::Particles; using namespace JinEngine::Filesystem; namespace JinEngine @@ -892,13 +894,8 @@ namespace JinEngine LUA_IMPLEMENT int l_newParticleSystem(lua_State* L) { - // Definition table. - if (!luax_istable(L, 1)) - { - luax_typerror(L, 1, "particle system definition table"); - return 1; - } - + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared<ParticleSystem>(new ParticleSystem(), Jin_Lua_ParticleSystem)); + return 1; } /* setFont(font) */ @@ -981,6 +978,7 @@ namespace JinEngine luaopen_SpriteSheet(L); luaopen_Animation(L); luaopen_Animator(L); + luaopen_ParticleSystem(L); luaL_Reg methods[] = { /* window */ diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp index a6c4eed..8c2e4c7 100644 --- a/src/lua/modules/graphics/je_lua_particle_system.cpp +++ b/src/lua/modules/graphics/je_lua_particle_system.cpp @@ -63,7 +63,7 @@ namespace JinEngine SharedParticleSystem ps = checkPS(L); float sx = luax_checknumber(L, 2); float sy = luax_checknumber(L, 3); - ps->setScale(sx, sy); + //ps->setScale(sx, sy); return 0; } @@ -71,14 +71,14 @@ namespace JinEngine { SharedParticleSystem ps = checkPS(L); bool b = luax_checkbool(L, 2); - ps->pause(b); + //ps->pause(b); return 0; } LUA_IMPLEMENT int l_clear(lua_State* L) { SharedParticleSystem ps = checkPS(L); - ps->clear(); + //ps->clear(); return 0; } |