I have two functions that define keyframes to animate in x or y axis. They only differ whether its horizontal or vertical.
function edgeh_prefab(st, y)
return {
keyframe(m_pos, 0, 120,
{64, y}, {64, y}),
keyframe(m_scale, 0,60,
{16,-1}, {16,8}),
keyframe(m_scale, 90,30,
{16,8}, {16,-1})
}
end
function edgev_prefab(st, x)
return {
keyframe(m_pos, 0, 120,
{x, 64}, {x, 64}),
keyframe(m_scale, 0,60,
{-1, 16}, {8, 16}),
keyframe(m_scale, 90,30,
{8,16}, {-1,16})
}
end
I have several other functions that are mostly the same except x and y parameters switched. I wonder if I could simplify this code so I don't have to deal with horizontal and vertical separately. Also I don't want to give extra parameters to check whether it's horizontal or vertical to define the x and y parameters.
Aucun commentaire:
Enregistrer un commentaire