small medium large xlarge

08fb87e_pragsmall
13 Mar 2009, 02:43
Tom H (8 posts)

I’ve added an animation to the actions dictionary for my layer to reduce the opacity to 0.0f from its current value.

The animation works just fine the first time I use it. But then, as expected, when I want to use it a second (or third, etc.) time no animation occurs. This is b/c the value of opacity is 0, setting the opacity to 1.0f fires the action which in turn animates the layers opacity from its current value (0) to 0 – and no (visibile) animation occurs.

Is there a means by which an action can be temporarily ‘turned off’ or otherwise told not to fire? That is, I’d like to be able to set my layers opacity to 1.0f without the animation taking place. Then, I’d like to be able to set the layer’s opacity to 0 (or some other vlaue) and have the action fire/animation occur.

FWIW, I’ve worked around this by not adding the animation as an action and instead just adding the animation to the layer when I want it to run.

From what (I think that) I’ve learned from Bill’s CA book and a couple other posts here @ PP, the action changes the value of the property while adding an animation only animates the change to the property (but leaves the original value intact). Correct?

thanks

tom

Biopic_100x100_pragsmall
27 Mar 2009, 10:25
Bill Dudney (917 posts)

Hi Tom,

Yep you are correct, mostly. Adding an animation to the actions dictionary puts your animation in the search path before the default animation. So when you change a property your animation is used instead of the default to achieve the visual change (and thus the animation) in the layer.

When you ad an animation directly (through the addAction:… method) you are explicitly animating but not changing the property. So when the animation is done, assuming that the toValue on the animation is not equal to the actual value currently on the layer , you will get a jump back to the actual value.

If you don’t want the jump back then you need to set the value to be equal to the toValue on your animation or tell the animation not to go away when finished (don’t remember the property off hand).

Hope this makes sense, if not please repost and I’ll try to further clarify.

Good Luck!

08fb87e_pragsmall
27 Mar 2009, 16:07
Tom H (8 posts)

Many thanks Bill. I think that I’ve got a good handle on it now.

Hoping to get this tile game out to the store by mid April. If you are interested, I’ll send you a promo code.

Thanks again –

tom

p.s. trying to find my way to WWDC – would be great to meet up to say thanks personally!

Biopic_100x100_pragsmall
27 Mar 2009, 21:04
Bill Dudney (917 posts)

Hey Tom,

Yeah I’d love to have your game!

Congratulations, looking forward to it.

You must be logged in to comment