Transition rotation attribute is not right?

I am using transition.to (instance, {rotation = 60, time = 500}) when the trigger is allocated to a click event, when pressed when he turn right 60 degrees, loosen after reduction, when the actual test, first click to run correctly, click on the second time he has rotated 120 degrees after that has been rotated 120 degrees, what is the reason?

You have not said what it is you’re turning.

You have not provided code.

I suspect that the second transition is rotating to the same value, because the starting rotation value is the current position.

Can you post your code?

function M.newButton1(x,y,radius, key)  --建立按钮

  local instance

key = key or “buttonA”

vertices = { 0,-113, 98,-58, 98,58, 0,113, -98,58, -98,-58,}

instance = display.newPolygon( 196, 226, vertices )

instance.fill = {type = “image”,filename = radius}

–function instance.touch(instance,event)

  function instance:touch(event)

    local phase = event.phase --设备监控

if x > display.contentCenterX then

road = 60

else

road = -60

end

    if phase==“began” then  --触摸按下

      if event.id then stage:setFocus(event.target, event.id) end--  按钮关联顶层显示对象???

      instance._xScale, instance._yScale = instance.xScale, instance.yScale  --保存按钮原有大小

      instance.xScale, instance.yScale = instance.xScale * 0.95, instance.yScale * 0.95–按钮变小一点

 instance:setFillColor(0.8)

transition.to(instance, {rotation = road , time = 100})

      local keyEvent = {name = “key”, phase = “down”, keyName = key or “none”}

      Runtime:dispatchEvent(keyEvent)–关联动作

elseif phase==“ended” or phase == “canceled” then

      if event.id then stage:setFocus(nil, event.id) end

      instance.xScale, instance.yScale = instance._xScale, instance._yScale–返回按钮原有大小

 instance:setFillColor(1)

transition.to(instance, {rotation = 0-road , time = 100})

      local keyEvent = {name = “key”, phase = “up”, keyName = key or “none”}

      Runtime:dispatchEvent(keyEvent)

    end

    return true

  end

  

  

  

  function instance:activate()

    self:addEventListener(“touch”)

  end

  function instance:deactivate()

    self:removeEventListener(“touch”)

  end

  instance:activate()

instance.x,instance.y = x,y  

  return instance

end

The above is my code, a button, when pressed his color change and become small and rotate 60 degrees, when the release back and reset 60 degree rotation, the actual process of testing, the first time he is the accurate rotation, after it has been wrong, rotate 120 degrees , can see what the reason for it?

If I understood you correctly (english is not my native language) below you find explanation of your problem.

60 - ( -60 ) = 60 + 60 = 120. If you want go back to start position you need use in second transition rotation = 0. 

yes,this is right!thanks very much!

You have not said what it is you’re turning.

You have not provided code.

I suspect that the second transition is rotating to the same value, because the starting rotation value is the current position.

Can you post your code?

function M.newButton1(x,y,radius, key)  --建立按钮

  local instance

key = key or “buttonA”

vertices = { 0,-113, 98,-58, 98,58, 0,113, -98,58, -98,-58,}

instance = display.newPolygon( 196, 226, vertices )

instance.fill = {type = “image”,filename = radius}

–function instance.touch(instance,event)

  function instance:touch(event)

    local phase = event.phase --设备监控

if x > display.contentCenterX then

road = 60

else

road = -60

end

    if phase==“began” then  --触摸按下

      if event.id then stage:setFocus(event.target, event.id) end--  按钮关联顶层显示对象???

      instance._xScale, instance._yScale = instance.xScale, instance.yScale  --保存按钮原有大小

      instance.xScale, instance.yScale = instance.xScale * 0.95, instance.yScale * 0.95–按钮变小一点

 instance:setFillColor(0.8)

transition.to(instance, {rotation = road , time = 100})

      local keyEvent = {name = “key”, phase = “down”, keyName = key or “none”}

      Runtime:dispatchEvent(keyEvent)–关联动作

elseif phase==“ended” or phase == “canceled” then

      if event.id then stage:setFocus(nil, event.id) end

      instance.xScale, instance.yScale = instance._xScale, instance._yScale–返回按钮原有大小

 instance:setFillColor(1)

transition.to(instance, {rotation = 0-road , time = 100})

      local keyEvent = {name = “key”, phase = “up”, keyName = key or “none”}

      Runtime:dispatchEvent(keyEvent)

    end

    return true

  end

  

  

  

  function instance:activate()

    self:addEventListener(“touch”)

  end

  function instance:deactivate()

    self:removeEventListener(“touch”)

  end

  instance:activate()

instance.x,instance.y = x,y  

  return instance

end

The above is my code, a button, when pressed his color change and become small and rotate 60 degrees, when the release back and reset 60 degree rotation, the actual process of testing, the first time he is the accurate rotation, after it has been wrong, rotate 120 degrees , can see what the reason for it?

If I understood you correctly (english is not my native language) below you find explanation of your problem.

60 - ( -60 ) = 60 + 60 = 120. If you want go back to start position you need use in second transition rotation = 0. 

yes,this is right!thanks very much!