mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-02 18:25:30 +02:00
Support for image animations.
This commit is contained in:
@@ -295,3 +295,59 @@ int LuaImage::setLayer(lua_State *l)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaImage::animate(lua_State *l)
|
||||
{
|
||||
Image *i = (Image *)lua_tointeger(l, 1);
|
||||
bool loop = (lua_toboolean(l, 2) != 0);
|
||||
|
||||
i->animate(loop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaImage::addAnimation(lua_State *l)
|
||||
{
|
||||
Image *i = (Image *)lua_tointeger(l, 1);
|
||||
if(!i) return 0;
|
||||
|
||||
float duration = (float)lua_tonumber(l, 2);
|
||||
|
||||
if (!lua_istable(l, 3)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ComponentData newInfo;
|
||||
newInfo.clearMask(COMPONENT_DATA_ALL_MASK);
|
||||
|
||||
lua_pushstring (l, "x");
|
||||
lua_gettable(l, -2);
|
||||
if(!lua_isnil(l, -1))
|
||||
{
|
||||
newInfo.setMask(COMPONENT_DATA_X_MASK);
|
||||
newInfo.x = (int)luaL_optinteger(l, -1, i->info.x);
|
||||
}
|
||||
lua_pop(l, 1);
|
||||
|
||||
lua_pushstring (l, "y");
|
||||
lua_gettable(l, -2);
|
||||
if(!lua_isnil(l, -1))
|
||||
{
|
||||
newInfo.setMask(COMPONENT_DATA_Y_MASK);
|
||||
newInfo.y = (int)luaL_optinteger(l, -1, i->info.y);
|
||||
}
|
||||
lua_pop(l, 1);
|
||||
|
||||
lua_pushstring (l, "alpha");
|
||||
lua_gettable(l, -2);
|
||||
if(!lua_isnil(l, -1))
|
||||
{
|
||||
newInfo.setMask(COMPONENT_DATA_ALPHA_MASK);
|
||||
newInfo.alpha = (float)luaL_optnumber(l, -1, i->info.alpha);
|
||||
}
|
||||
lua_pop(l, 1);
|
||||
|
||||
newInfo.duration = duration;
|
||||
i->addAnimation(newInfo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user