Hi
In my game the idea is that if the character is moving, then his energy increases. On the contrary, as soon as he stops, the energy starts decreasing.
I was tryin to do this with performWithDelay function, but with no succes. Here are the functions involved. Where you can see the dotted line, there was the timer.performWithDelay(1000, de(in)creaseEnergy) call.
local function decreaseEnergy(arm) energyH[arm.myName] = energyH[arm.myName] - 1 leftValue.text = energyH.handL rightValue.text = energyH.handR end local function increaseEnergy(arm) energyH[arm.myName] = energyH[arm.myName] + 0.5 leftValue.text = energyH.handL rightValue.text = energyH.handR end local function energy(event, arm) --event = event.phase, arm = event.target if (arm.myName == "handL") or (arm.myName == "handR") then if (event == "ended") and (arm.bodyType == "static") then --energy down, ................ elseif (event == "began") or (arm.bodyType == "dynamic") then --energy up, ................ end end end
Then I include the function ENERGY into my startDrag function which is attached the to button listeners. Is there a better way to this? Thank’s for all the efforts…
Tomaz