I want to be able to set the value of a variable (BallsbeingDest) depending on whether an animation is playing or not. This is what I have come up with but it’s not working. Any help is appreciated.
local sheetInfofruitblaster = require("Animations\_FruitBlaster") local animation\_fruitblaster = graphics.newImageSheet("images/Animations\_FruitBlaster.png", sheetInfofruitblaster:getSheet()) local sequences\_fruitblaster = { -- consecutive frames sequence { name = "default", start = 1, count = 5, time = 1100, loopCount = 1, loopDirection = "forward" } } local function playAnimationFruitBlaster(params) BallsbeingDest=1 local fruitblaster = display.newSprite(layers.matchanimations, animation\_fruitblaster,sequences\_fruitblaster) fruitblaster.x = params.x fruitblaster.y = params.y fruitblaster:play() function fruitblasterlistener(event) if (event.phase=="ended") then ---I can't use 'event.phase == began' because other stuffhappening elsewhere --- in the code might change BallsbeingDest ---which I don't want while the animation is playing-------- BallsbeingDest = 0 fruitblaster:removeSelf() fruitblaster = nil end end function fruitblasterwhatever() if sequences\_fruitblaster.isPlaying=="true" then print("bale") ---I am using this to see if it is working--- BallsbeingDest=1 end end Runtime:addEventListener("enterFrame", fruitblasterwhatever) fruitblaster:addEventListener("sprite", fruitblasterlistener) end