Hi guys,
I’ve been trying to get this little piece of code to work but without any luck, this is the code:
local function turnCircle(event) local beginPos if event.phase == "began" then beginPos = level.rotation print(beginPos) elseif event.phase == "moved" then level.rotation = beginPos -(event.x - event.xStart) end return true end
It stores the begin rotation of the object and stores that in beginPos. But I keep getting the following error:
ERROR: attempt to perform arithmetic on local ‘beginPos’ (a nil value)
The error points to the variable beginPos used in the “moved” if condition. I don’t get how it could be nil, I clearly declared it in the correct scope and I assign a value to it in the “began” condition.
Any thoughts?
Kind regards
Bram