objective c - Button not moving randomly -


I have to unmatch a button randomly and have to click on it to a user even if they have the right amount If not, then it disappears and I want to take it to a different place. However, whenever I do not click on it, it appears in the same position on the right screen. Here's my code.

  - (IBAction) randomRed: (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-1; [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]; }     

itemprop = "text">

drand48 () is a preferred random generator, so it is only psuedo-random . At the beginning of your program, you can call srand48 (int), and then when you need a random number, use drand48 (). The integer you use in srand48 (int) is "seed" for your random number; This means that the sequence of "random" numbers will be used every time you use that seed.

Not so random, you say? If you want something else, try arc4random () to make life easier, you can use arc4random ()% x to get a random number at range 0 - (x-1).

Hope it helps!

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -