--object is your circle function object:touch(event) if event.phase == "began" then display.getCurrentStage():setFocus(self); self.currPos = self.x; elseif event.phase == "moved" then self.x, self.y = event.x, event.y; if self.x \> self.currPos then self.angularVelocity = -50; elseif self.x \< self.currPos then self.angularVelocity = 50; end self.currPos = self.x; elseif event.phase == "ended" then display.getCurrentStage():setFocus(nil); end end
Basically you store the previous position X of the object (if we want for it to change rotation when the x changes), and then compare it to the current position to change the angularVelocity of the object to the desired direction.
--object is your circle function object:touch(event) if event.phase == "began" then display.getCurrentStage():setFocus(self); self.currPos = self.x; elseif event.phase == "moved" then self.x, self.y = event.x, event.y; if self.x \> self.currPos then self.angularVelocity = -50; elseif self.x \< self.currPos then self.angularVelocity = 50; end self.currPos = self.x; elseif event.phase == "ended" then display.getCurrentStage():setFocus(nil); end end
Basically you store the previous position X of the object (if we want for it to change rotation when the x changes), and then compare it to the current position to change the angularVelocity of the object to the desired direction.