Hello,
I am trying to make it so that a ‘virus’ in my game moves continuously… I am using transition.to to make it move to a random x,y coordinate, and onComplete it should move again to a new coordinate.
For some reason the way I have it set up keeps giving me a stack overflow and it doesn’t wait for the delay that is set up… it just fires both functions repeatedly.
Any help will be GREATLY appreciated.
function Virus:moveAgain() print("moveAgain") local destinationX = math.random(45,275) local destinationY = math.random(45,435) self.\_transition = transition.to( self.\_visual, { time = 2000, alpha = 1, x = destinationX, y = destinationY, onComplete = Virus:moveVirus() } ) end function Virus:moveVirus(destinationX, destinationY) print("moveVirus") local destinationX = destinationX or math.random(45,275) local destinationY = destinationY or math.random(45,435) --print("Im in moveVirus... I will move in X:"..destinationX.." and Y: "..destinationY) self.\_transition = transition.to( self.\_visual, { time = 2000, alpha = 1, x = destinationX, y = destinationY, onComplete = Virus:moveAgain() } ) end