I have the following code in which a person object receives a message to cross a bridge.
The person object’s current state is states.WALKING and the animation of their “y” property is used to show them walking up and then down a bridge.
The person object has a current velocity which combined with the time the animation takes to complete has them crossing the bridge just as they return to the second 0 value in the custom easing vector.
local function descend_bridge(self)
self.state = states.WALKING
end
function on_message(self, message_id, message, sender)
if message_id == hash("cross_bridge") then
if self.state~=states.ON_BRIDGE then
self.state = states.ON_BRIDGE
local pos = go.get_position()
local values = { 0, .2, .5, .7, .5, .2, 0 }
local bridge_easing = vmath.vector(values)
go.animate(".", "position.y", go.PLAYBACK_ONCE_FORWARD, pos.y+300, bridge_easing, 10, 0, descend_bridge)
end
end
end
This works most of the time, but sometimes the callback does not get called and the person’s state does not return to states.WALKING.
Normally I can see the person traverse the custom easing curve, but in the cases where the callback doesn’t work I can see them very quickly kind of bump up and down on the Y axis.
I’m not sure why this is happening, continuing to try and debug, but I thought I’d post this just in case I was doing something wrong.
Thanks,
Alex