hi,
after a bad night to find the solution…can you help me.
I want only stop an transition to put a another (with transitionRight or transitionLeft ) but i can’t do it
- my button right and left don’t work good
- text touchright and touchleft don’t appear
- sometimes i have graphical problem because my circle jump to an opposite position
it would be nice if you can take a look on this simplified snippet
display.setStatusBar( display.HiddenStatusBar ) local CircleonTransition = display.newCircle( 150, 200, 100 ) CircleonTransition:setFillColor( 1,1,1 ) CircleonTransition.x = 150 CircleonTransition.y = 200 CircleonTransition.xScale = 0.1 CircleonTransition.yScale = 0.1 local textInfo = display.newText("", 240,105,native.systemFont,40) textInfo:setFillColor(1,1,1) local number = 1 local timeTransition = 5000 local circleLeftButton = display.newCircle(52,105,30) circleLeftButton.alpha = 0.5 local circleRightButton = display.newCircle(427,105,30) circleRightButton.alpha = 0.5 local side = 200 local sideLeft = 380 local sideRight = 50 local souffleRightx =200 local souffleLeftx = 300 function randomSide() print("randomside") choix = math.random(0,1) if choix == 0 then side = sideLeft else side = sideRight end return side end function displacement() randomSide() function displacementitself() textInfo.text = "(".."displacement"..")" transition.to(CircleonTransition, { tag="movecharacter", time=timeTransition, x=side, y=CircleonTransition.y, transition=easing.inOutExpo, onComplete=displacement}) return side end displacementitself() end local function stopDisplacement() textInfo.text = "(".."stop"..")" transition.cancel("movecharacter") end local function transitionRight() textInfo.text = "(".."right"..")" stopDisplacement() transition.to(CircleonTransition, {tag="souffleRight", time=timeTransition, x=souffleRightx, y=CircleonTransition.y, rotation=-720, transition=outQuad, onComplete=displacement}) return textInfo end local function transitionLeft() textInfo.text = "(".."left"..")" stopDisplacement() transition.to(CircleonTransition, {tag="souffleLeft", time=timeTransition, x=souffleLeftx, y=CircleonTransition.y, rotation=45, transition=outQuad, onComplete=displacement}) return textInfo end circleLeftButton.touch = function( self, event ) if event.phase == "began" then textInfo.text = "(".."touchleft"..")" transitionLeft() end return textInfo end Runtime:addEventListener( "touch", circleLeftButton ) circleRightButton.touch = function( self, event ) if event.phase == "began" then textInfo.text = "(".."touchright"..")" transitionRight() end return textInfo end Runtime:addEventListener( "touch", circleRightButton ) timer.performWithDelay( 100, displacement )