Beri
Beri

Reputation: 245

Corona SDK moving display objects randomly in 4 direction?

How do I move a display object in four direction using Corona SDK? I am in development of a maze game where the enemies has to movie randomly in four direction.

example I have tried it so:

function transtionBack()
    transition.to(police, {time = 1000, x = police.x, y = 0, onComplete = transtionTo() })
end


function transtionTo()
    transition.to(police, {time = 1000, x = police.x, y = 400, onComplete = transtionBack() })
end
transtionTo()

This doesn't seems to work; anyone have a better idea?

Upvotes: 2

Views: 170

Answers (1)

Beri
Beri

Reputation: 245

I think i found the problem

function transtionBack()
    transition.to(police, {time = 1000, x = police.x, y = 0, onComplete = transtionTo })
end


function transtionTo()
    transition.to(police, {time = 1000, x = police.x, y = 400, onComplete = transtionBack })
end
transtionTo()

Upvotes: 2

Related Questions