This is a continuation of my first post but since it is a tangent I thought I would start a new thread. In any case, I was thinking about getting my objects to change states in an orderly fashion and it was brought up in the last thread that I should just cancel my old transition before starting a new one. As I thought that was a great idea I got to thinking that I do stuff in the callback for that first transition. For example:
What if I don’t want the gamer to be able to move the hero while he is rotating from left to right. Otherwise, it looks stupid because hero is pulled sideways. So I have some logic that says
movefunction()
if not hero.isRotating then
movehero()
end
end
Later in the code I set the hero.isRotating flag on right before the transition begins and depend on the callback to set if off.
If I want to do something else that needs to cancel the first transition, it also cancels the run of the callback function and the isRotating flag is stuck on which of course leaves the hero stuck in the middle of the screen not accepting input from anything because he thinks he is rotating. Who here thinks the callback should run when the transition is cancelled? There are probably cases where you would need it and cases where it messes things up. Who knows.
Just has a test case I ran this:
local function testsomething () local function callback1 (obj) print("test case listener1 ended") return end print ("start of test case --------------------------------------") local test1 = transition.to(hero.image, {time=4000, delay=0, alpha = 1 , transition = easing.inOutExpo , onComplete = callback1 }) transition.cancel(test1) return end
Callback1 was never called.
This is probably standard stuff for the seasoned game programmer but I thought I would share just in case someone else might benefit.
So in my case, if the rotation is less than 100 degrees I use a transition to rotate him. Over 100 degrees I trigger a sprite animation and depend on the spritelistener to set the rotation flag off. So there is the added complexity of syncing up transitions and sprite animations.
fun times, fun times.