ios - Fade Button in and Out While being clicked/not clicked -
I am trying to bring a button to go to random places within my scene. However, the dot only runs on random when it is pressed if it is not pressed, then I also want to fade it in a different place. I used CGRect
because I need a dot to be within the range of a particular view
- (IBAction) random red: (ID sender { [Auto red dot]; CGRCT senderframe = [sender frame]; CGRact superbound = [[sender supervision] border]; Senderfram.orine.x = (superboxious.width - senderframe-size.width) * dracon48 (); SenderFrame.origin.y = (Superboxize. Highlight - Sender Frame Size. Highlight) * drand48 (); [Sender setframe: senderframe]; Counter = counter - 5; ScoreLabel.text = [NSString stringWithFormat: @ "Points% i", Counter]; NSString * path = [[NSBundle main bundle] Pathfoser resource: @ "Tapped dot red dot buzzer short" type: @ "MP3"]; Sound = [[aviideo player] alloc] initWithContentsOfURL: [nsur fileURLWithPath: path] error: NULL]; Sound.numberOfLoops = 1; [Sound play]; [Self subtractOne]; [Self Performance Selector: @Selector (Showdot) withObject: After zero: 1.0]; } - (zero) startRedDot {if (counter == 0) redDot = [NSTimer Scheduled timer with time interval: 4.0 target: auto selector: @ searcher (showRedDot) userInfo: zero repeats: yes]; } - (zero) showRedDot {[UIView startup permissions: zero reference: NULL]; [UIView Set Animation Duration: 1.0]; [Redbutton set alpha: 1]; [UIView commitAnimations]; [Self Performance Selector: Object with @Selector (red dot): After zero: 1.0]; } - (zero) red dot {[UIView startup permissions: zero reference: NULL]; [UIView Set Animation Duration: 0.5]; [Redbutton set alpha: 0]; [UIView commitAnimations]; } - (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view [Self Setup Game]; [Self-shaping]; }
Currently your random status code is called only when the button is pressed is.
To press it, it should be put in its own method, which can be adopted only after a set period.
First we can manipulate the button that you want to move in the context of the example.
Then the movement code separates the code into its own method.
- Exclude (zero) driving button; CGPoint newPosition; // Get limitations. With = self.view.frame.size.width - button.frame.size.width; Limitations. Heel = self. View. Frame Eyes Hight-button.frame.height.height; // Calculate the new position newPosition = (CGPOON) {limits.width * drand48 (), limits.height * drand48 ()}; // Set new frame button Frame = (cgartact) {newness, button.frame.image}; }
Change it to your startRedDot, which will create, and launch the timer.
- (zero) start date ruddot {redDotTimer = [NSTimer scheduling time with time: 4.0 targets: self selector: @sillector (move-based orderless) user information: zero repeats: yes ]; [Red dot timer fire]; }
Animation is simply simple to create a new method that calls two animations; The one who fades the button completing the button, and closes the next animation to fade it back.
- Animation with {0} driving button {CGFloat fadeDurration; If (! Button) return; // Call the button only if it exists fadeDurration = 0.4; // Fade Out [UIView Animation with Diction: Feed Duration Animation: ^ {button.alpha = 0.0f; } Closing: ^ (BOOL Finish) {// Move the button, while it is not visible [Walk Manually] // Fade In [UIView Cheat Realism: Feed Duration Animation: ^ {button.alpha = 1.0f; }]; }]; }
Edit timer selector to be an animation method in the end.
- (zero) startup redhat {redDotTimer = [NSTimer Scheduled Timer with Time Interface: 4.0 Target: Self Selector: @Selector (Animation with Movement Button) User Information: Zero Repeats: Yes] ; [Red dot timer fire]; }
Comments
Post a Comment