Hi all,
I am wondering if it is possible to get the name of params passed to a function, I am trying to write a helper module that I can use with transitions.
Hopefully it will store the original values of an object before it is transitioned and then when a second function is called it will transition back to the original location. I have it working for normal transitions, but I have just realized that for transition involving effects that the list of potential attributes is quite large. Is there a way of converting the names of the params passed over so that I only store the ones that are changes and can just use these? Any other ideas?
Cheers,
Here is my code.
[lua]
local transitionHelper = {}
local listOfObjects = {}
function transitionHelper:newObject( object, params )
if not listOfObjects[object] then
listOfObjects[object] = {}
listOfObjects[object].object = object
print(“this is a new item”)
end
for k,v in pairs( params ) do
listOfObjects[object][k] = v
end
listOfObjects[object].xOld = object.x
listOfObjects[object].yOld = object.y
listOfObjects[object].rotationOld = object.rotation
listOfObjects[object].alphaOld = object.alpha
listOfObjects[object].xScaleOld = object.xScale
listOfObjects[object].yScaleOld = object.yScale
listOfObjects[object].widthOld = object.width
listOfObjects[object].heightOld = object.height
transition.to(object,{time = listOfObjects[object].time or 500, delay = listOfObjects[object].delay or 0,
delta = listOfObjects[object].delta, iterations = listOfObjects[object].iterations or 1,
tag = listOfObjects[object].tag, transition = listOfObjects[object].transition ,
x = listOfObjects[object].x, y = listOfObjects[object].y, rotation = listOfObjects[object].rotation,
alpha = listOfObjects[object].alpha, xScale = listOfObjects[object].xScale,
yScale = listOfObjects[object].yScale, width = listOfObjects[object].width,
height = listOfObjects[object].height, onComplete = listOfObjects[object].onComplete
})
end
function transitionHelper:returnObject( object, params )
transition.to(object,{time = params.time or listOfObjects[object].time or 500,
delay = params.delay or listOfObjects[object].delay or 0,
delta = params.delta or listOfObjects[object].delta,
iterations = params.iterations or listOfObjects[object].iterations or 1,
tag = params.tag or listOfObjects[object].tag,
transition = params.transition or listOfObjects[object].transition ,
x = listOfObjects[object].xOld, y = listOfObjects[object].yOld, rotation = listOfObjects[object].rotationOld,
alpha = listOfObjects[object].alphaOld, xScale = listOfObjects[object].xScaleOld,
yScale = listOfObjects[object].yScaleOld, width = listOfObjects[object].widthOld,
height = listOfObjects[object].heightOld, onComplete = listOfObjects[object].onComplete
})
end
return transitionHelper
[/lua]
Thanks,
Craig