Scaling and message passing

I have two problems, I can’t make my objects scaling down to 80% and back in loop. I tried

go.animate(go.get_id(), "scale", go.PLAYBACK_ONCE_FORWARD, 0.8, go.EASING_LINEAR, 2)
go.animate(go.get_id(), "scale", go.PLAYBACK_ONCE_BACKWARD, 1, go.EASING_LINEAR, 2)

but it doesn’t work. And another problem is I can’t stop my world. I use:

	if message_id == hash("contact_point_response") then
		if message.group == hash('hero') then
			msg.post("hero#script", "death")
			msg.post("/background/ground#script", "stop")

in object’s script and

if message_id == hash("stop") then
		self.speed = 0
	end

in ground’s script.
URL’s are right and first message to hero is sent well. How do I fix this problems?

1 Like

When you call go.animate() you tell the engine to start an animation. Your script will not stop and wait for the animation to finish. So what happens here is that you start two animations at the same time.

If you want to play two animation in succession, provide a callback to go.animate() that will be called on animation completion. See the ref docs for details:

1 Like