• 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: Smooth Animation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smooth Animation


  • Subject: Re: Smooth Animation
  • From: Rhon Fitzwater <email@hidden>
  • Date: Fri, 11 Jun 2004 21:01:12 -0400

Your solution worked perfect. Couldnt have asked for more. Many
thanks.

-Rhon
On Jun 11, 2004, at 8:50 PM, Daniel Waylonis wrote:

> On Jun 11, 2004, at 4:25 PM, Rhon Fitzwater wrote:
>
>> Right now I have my window so its alpha setting is set to 1.0 when
>> the mouse enters the window and 0.2 when the mouse exits, using this
>> code:
>>
>> //mouse entered exited window code below
>> - (void)viewDidMoveToWindow {
>> [self addTrackingRect:[self frame] owner:self userData:nil
>> assumeInside:NO];
>> [super viewDidMoveToWindow];
>> }
>>
>> - (void)mouseEntered:(NSEvent *)event {
>> NSLog(@"Mouse Entered");
>> [[self window] setAlphaValue:1.0];
>>
>> }
>>
>> - (void)mouseExited:(NSEvent *)event {
>> NSLog(@"Mouse Exited");
>> [[self window] setAlphaValue:0.2];
>> }
>> //end of mouse entered or exited window code
>>
>> What I want to know how to do is make the transition between alpha
>> settings smooth. gradually increase or decrease alpha settings. Can
>> someone tell me how this can be done, possible with some coding
>> examples?
>
> Hi Rhon,
>
> Try this:
>
> - (void)viewDidMoveToWindow {
> [self addTrackingRect:[self frame] owner:self userData:nil
> assumeInside:YES];
> [super viewDidMoveToWindow];
> }
>
> static float windowAlphaIncrement = 0.15;
> static float windowAlphaCurrentIncrement;
> static float windowAlphaMin = 0.2;
> static float windowAlphaMax = 1.0;
> static float windowAlphaFadeRate = 1.0 / 15.0;
>
> - (void)changeTransparency:(NSTimer *)timer
> {
> float alpha = [[self window] alphaValue];
> BOOL reschedule = NO;
>
> alpha += windowAlphaCurrentIncrement;
>
> // Reschedule timer if we haven't reached desired value
> if (windowAlphaCurrentIncrement > 0)
> {
> if (alpha < windowAlphaMax)
> reschedule = YES;
> else
> alpha = windowAlphaMax;
> }
> else
> {
> if (alpha > windowAlphaMin)
> reschedule = YES;
> else
> alpha = windowAlphaMin;
> }
>
> if (reschedule)
> [NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
> target:self selector:@selector(changeTransparency:) userInfo:nil
> repeats:NO];
>
> [[self window] setAlphaValue:alpha];
> }
>
> - (void)mouseEntered:(NSEvent *)event {
> NSLog(@"Mouse Entered");
>
> windowAlphaCurrentIncrement = windowAlphaIncrement;
> [NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
> target:self selector:@selector(changeTransparency:) userInfo:nil
> repeats:NO];
> }
>
> - (void)mouseExited:(NSEvent *)event {
> NSLog(@"Mouse Exited");
>
> windowAlphaCurrentIncrement = -windowAlphaIncrement;
> [NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
> target:self selector:@selector(changeTransparency:) userInfo:nil
> repeats:NO];
> }
>
> Dan
> _________________________________________________
> Dan Waylonis email@hidden
> Software Engineer http://www.nekotech.com
> nekotech SOFTWARE 650.964.2490 (O)

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Smooth Animation
      • From: Nicko van Someren <email@hidden>
References: 
 >Smooth Animation (From: Rhon Fitzwater <email@hidden>)
 >Re: Smooth Animation (From: Daniel Waylonis <email@hidden>)

  • Prev by Date: Re: Smooth Animation
  • Next by Date: I need one or two good crackers
  • Previous by thread: Re: Smooth Animation
  • Next by thread: Re: Smooth Animation
  • Index(es):
    • Date
    • Thread