• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Animated subviews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Animated subviews


  • Subject: Re: Animated subviews
  • From: Wyatt Webb <email@hidden>
  • Date: Sun, 23 Nov 2008 09:11:31 -0800

I have not done this myself, but I understand that you can find the "actual" positions of things in the middle of an animation by querying the [ [ myView layer ] presentationLayer ]. This is a version of the layer that has all of the current values in the middle of an animation. As long as you have a chance to check periodically, you should be able to do your comparisons.

Wyatt

On Nov 23, 2008, at 8:30 AM, DKJ wrote:

I have two subviews sv1 and sv2 that I've animated by setting their center properties inside of an animation block. This animation code is in sv1.m and sv2.m. It all works just fine: they both move smoothly around in the superview by choosing new centre points in a continuous loop. It looks quite cute, really.

What I want to do now is detect when they come within a certain distance of one another as they're moving. But when I do this to move them:

	sv1.center = p1;
	sv2.center = p2;

their center properties are set immediately to the new values: i.e. they can't be read to find the intermediate positions. So I can't use these properties to find out if their centres come within a given distance of one another.

I've thought of some possible approaches:

1. Having the superview controller calculate whether the lines between the animation start and finish points intersect, and whether sv1 and sv2 will be at the intersection at the same time.

2. Breaking up the straight line moves into much smaller segments and having the center properties set successively to those.

3. Having the superview controller handle the animation and somehow keep track of the subview's relative distances.

4. Using keyframe animation instead.

#1 seems rather complicated. #2 seems likely to lead to a choppy animation, and would rule out using the speed-up-then-slow-down animation mode. #3 would involve throwing out a lot of the code I've written so far. And I don't yet have a clue whether #4 is plausible, not having used keyframe animation before.

If there are any other suggestions, I'd be grateful to hear them!

dkj
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Animated subviews
      • From: DKJ <email@hidden>
    • Re: Animated subviews
      • From: DKJ <email@hidden>
References: 
 >Animated subviews (From: DKJ <email@hidden>)

  • Prev by Date: Animated subviews
  • Next by Date: Re: Animated subviews
  • Previous by thread: Animated subviews
  • Next by thread: Re: Animated subviews
  • Index(es):
    • Date
    • Thread