Advertisement
Guest User

Coin Implementation

a guest
Aug 15th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  RollViewController.m
  3.  
  4.  
  5.  
  6. // Each image view is a die.
  7. // The first coin is imageView.
  8.  
  9.  
  10. // Each image view uses the 6 png images in the resource folder to create the
  11.  
  12.  
  13. #import "TossViewController.h"
  14. #import "SelectCoinViewController.h"
  15. #import <CoreMotion/CoreMotion.h>
  16.  
  17. @implementation TossViewController
  18.  
  19. // This creates setter and getter methods for each of the imageViews automatically
  20. @synthesize toggleButton;
  21. @synthesize imageView,imageView2;
  22.  
  23. @synthesize animationSpeed;
  24. @synthesize hopsPerSecond;
  25. @synthesize motionManager;
  26.  
  27. @synthesize startLabel;
  28.  
  29. @synthesize coinOneA,coinOneB,coinOneC,coinOneD,coinOneE,coinOneF,coinOneG,coinOneH,coinOneI,coinOneJ;
  30.  
  31. @synthesize coinTwoA,coinTwoB,coinTwoC,coinTwoD,coinTwoE,coinTwoF,coinTwoG,coinTwoH,coinTwoI,coinTwoJ;
  32.  
  33. @synthesize headsTails, headsHeads, tailsHeads, tailsTails;
  34.  
  35.  
  36.  
  37.  
  38. int xCoin = 0;      // This variable is used to record the start up of the dice game.
  39. // It is used to prevent didViewLoad from rolling the dice on statup
  40. // when it is called
  41.  
  42. int amountSelectedCoin = 0; // local varibale to store the amount returned from the Selection method
  43. // called returnSelection
  44. // default value of 0, which gives one view
  45.  
  46. int r; // used for random side generation, the current toss
  47. int r2;
  48.  
  49. int l = 1; // used to record what the last flip was, initialised to heads
  50. int l2 = 1;
  51.  
  52. int i; // used to fill the current animation array to be used
  53. int i2;
  54.  
  55. int initArrays = 0;
  56. int labelcount;     // int to keep track of the label values
  57.  
  58.  
  59.  
  60.  
  61.  
  62. NSMutableArray *randAnimation;
  63. NSMutableArray *randAnimation2;
  64.  
  65. NSString *coinOneStringVal;
  66. NSString *coinTwoStringVal;
  67.  
  68. bool *animationFinished;
  69.  
  70.  
  71. -(void) updateLabels {              // the method that controls the update of the coinX labels
  72.    
  73.     switch (labelcount)
  74.     {                                           // Golden Lesson, Strings Use %@ for output
  75.         case 1:
  76.             coinOneA.text = [NSString  stringWithFormat:@" "];
  77.             coinTwoA.text = [NSString  stringWithFormat:@" "];
  78.             coinOneB.text = [NSString  stringWithFormat:@" "];
  79.             coinTwoB.text = [NSString  stringWithFormat:@" "];
  80.             coinOneC.text = [NSString  stringWithFormat:@" "];
  81.             coinTwoC.text = [NSString  stringWithFormat:@" "];
  82.             coinOneD.text = [NSString  stringWithFormat:@" "];
  83.             coinTwoD.text = [NSString  stringWithFormat:@" "];
  84.             coinOneE.text = [NSString  stringWithFormat:@" "];
  85.             coinTwoE.text = [NSString  stringWithFormat:@" "];
  86.             coinOneF.text = [NSString  stringWithFormat:@" "];
  87.             coinTwoF.text = [NSString  stringWithFormat:@" "];
  88.             coinOneG.text = [NSString  stringWithFormat:@" "];
  89.             coinTwoG.text = [NSString  stringWithFormat:@" "];
  90.             coinOneH.text = [NSString  stringWithFormat:@" "];
  91.             coinTwoH.text = [NSString  stringWithFormat:@" "];
  92.             coinOneI.text = [NSString  stringWithFormat:@" "];
  93.             coinTwoI.text = [NSString  stringWithFormat:@" "];
  94.             coinOneJ.text = [NSString  stringWithFormat:@" "];
  95.             coinTwoJ.text = [NSString  stringWithFormat:@" "];
  96.             coinOneA.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  97.             coinTwoA.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  98.             break;
  99.         case 2:
  100.             coinOneB.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  101.             coinTwoB.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  102.             break;
  103.         case 3:
  104.             coinOneC.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  105.             coinTwoC.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  106.             break;
  107.         case 4:
  108.             coinOneD.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  109.             coinTwoD.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  110.             break;
  111.         case 5:
  112.             coinOneE.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  113.             coinTwoE.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  114.             break;
  115.         case 6:
  116.             coinOneF.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  117.             coinTwoF.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  118.             break;
  119.         case 7:
  120.             coinOneG.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  121.             coinTwoG.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  122.             break;
  123.         case 8:
  124.             coinOneH.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  125.             coinTwoH.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  126.             break;
  127.         case 9:
  128.             coinOneI.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  129.             coinTwoI.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  130.             break;
  131.         case 10:
  132.             coinOneJ.text = [NSString  stringWithFormat:@"%@", coinOneStringVal];
  133.             coinTwoJ.text = [NSString  stringWithFormat:@"%@", coinTwoStringVal];
  134.             labelcount = 0; // reset labelcount
  135.             break;
  136.         default:
  137.             return;
  138.             break;
  139.     }
  140.    
  141.     self.view.userInteractionEnabled = YES;   // reenable user interaction
  142.     // after touches complete
  143. }
  144.  
  145.  
  146. // This action is triggered by the user rolling the dice.
  147. -(IBAction) toggleAnimation:(id)sender {
  148.     xCoin = 2;      // set x greater than 0, to allow the dice to be rolled.
  149.     // now that the program will have already loaded.
  150.    
  151.    
  152.    
  153.     [self callValueFromSelect];             // calls this self method that accesses the
  154.     // value from the Select class .m file
  155.    
  156.     [self rollTheDice];                     // calls the viewDidLoad Class, generate random array ( roll pattern) and display.
  157.    
  158. }
  159.  
  160. -(void) fillArrays{
  161.    
  162.    
  163.     // **********************************
  164.     // **** Create the 4 Animations *****
  165.     // **********************************
  166.    
  167.    
  168.     /* A much more efficient way to do this is
  169.      
  170.      NSTimer *imageTimer;
  171.      int animationCount;
  172.      
  173.      -(void) startAnimation
  174.      {
  175.      imageTimer = [NSTimer scheduledTimerWithInterval:.1 target: self selector:@selector(switchImage) userInfo:nil repeats:YES];
  176.      }
  177.      
  178.      
  179.      -(void)switchImage
  180.      {
  181.      NSString *imageName = [NSString stringWithFormat:@"timer%i", animationCount];
  182.      
  183.      UIImage *image = [UIImage imageNamed:imageName];
  184.      someImageView.image = image;                        // possibly without this line
  185.      // instead load array here
  186.      }
  187.      
  188.      */
  189.    
  190.    
  191.    
  192.    
  193.     // Need to created the specific array of images for hh, ht, th and tt
  194.    
  195.     headsTails =[[NSMutableArray alloc] initWithObjects:    // the array is initialised with these // png images.
  196.                  [UIImage imageNamed:@"Frame 1ht.png"], // 0
  197.                  [UIImage imageNamed:@"Frame 2ht.png"],
  198.                  [UIImage imageNamed:@"Frame 3ht.png"],
  199.                  [UIImage imageNamed:@"Frame 4ht.png"],
  200.                  [UIImage imageNamed:@"Frame 5ht.png"],
  201.                  [UIImage imageNamed:@"Frame 6ht.png"],
  202.                  [UIImage imageNamed:@"Frame 7ht.png"],
  203.                  [UIImage imageNamed:@"Frame 8ht.png"],
  204.                  [UIImage imageNamed:@"Frame 9ht.png"],
  205.                  [UIImage imageNamed:@"Frame 10ht.png"],
  206.                  [UIImage imageNamed:@"Frame 11ht.png"],
  207.                  [UIImage imageNamed:@"Frame 12ht.png"],
  208.                  [UIImage imageNamed:@"Frame 13ht.png"],
  209.                  [UIImage imageNamed:@"Frame 14ht.png"],
  210.                  [UIImage imageNamed:@"Frame 15ht.png"],
  211.                  [UIImage imageNamed:@"Frame 16ht.png"],
  212.                  [UIImage imageNamed:@"Frame 17ht.png"],
  213.                  [UIImage imageNamed:@"Frame 18ht.png"],
  214.                  [UIImage imageNamed:@"Frame 19ht.png"],
  215.                  [UIImage imageNamed:@"Frame 20ht.png"],
  216.                  [UIImage imageNamed:@"Frame 21ht.png"],
  217.                  [UIImage imageNamed:@"Frame 22ht.png"],
  218.                  [UIImage imageNamed:@"Frame 23ht.png"],
  219.                  [UIImage imageNamed:@"Frame 24ht.png"],
  220.                  [UIImage imageNamed:@"Frame 25ht.png"],
  221.                  [UIImage imageNamed:@"Frame 26ht.png"],
  222.                  [UIImage imageNamed:@"Frame 27ht.png"],
  223.                  [UIImage imageNamed:@"Frame 28ht.png"],
  224.                  [UIImage imageNamed:@"Frame 29ht.png"],
  225.                  [UIImage imageNamed:@"Frame 30ht.png"],
  226.                  [UIImage imageNamed:@"Frame 31ht.png"],
  227.                  [UIImage imageNamed:@"Frame 32ht.png"],
  228.                  [UIImage imageNamed:@"Frame 33ht.png"],
  229.                  [UIImage imageNamed:@"Frame 34ht.png"],
  230.                  [UIImage imageNamed:@"Frame 35ht.png"],
  231.                  [UIImage imageNamed:@"Frame 36ht.png"],
  232.                  [UIImage imageNamed:@"Frame 37ht.png"],
  233.                  [UIImage imageNamed:@"Frame 38ht.png"],
  234.                  [UIImage imageNamed:@"Frame 39ht.png"],
  235.                  [UIImage imageNamed:@"Frame 40ht.png"],
  236.                  [UIImage imageNamed:@"Frame 41ht.png"],
  237.                  [UIImage imageNamed:@"Frame 42ht.png"],
  238.                  [UIImage imageNamed:@"Frame 43ht.png"],
  239.                  [UIImage imageNamed:@"Frame 44ht.png"],
  240.                  [UIImage imageNamed:@"Frame 45ht.png"],
  241.                  [UIImage imageNamed:@"Frame 46ht.png"],
  242.                  [UIImage imageNamed:@"Frame 47ht.png"],
  243.                  [UIImage imageNamed:@"Frame 48ht.png"],
  244.                  [UIImage imageNamed:@"Frame 49ht.png"],
  245.                  [UIImage imageNamed:@"Frame 50ht.png"],
  246.                  [UIImage imageNamed:@"Frame 51ht.png"],
  247.                  [UIImage imageNamed:@"Frame 52ht.png"],
  248.                  [UIImage imageNamed:@"Frame 53ht.png"],
  249.                  [UIImage imageNamed:@"Frame 54ht.png"],
  250.                  [UIImage imageNamed:@"Frame 55ht.png"],
  251.                  [UIImage imageNamed:@"Frame 56ht.png"],
  252.                  [UIImage imageNamed:@"Frame 57ht.png"],
  253.                  [UIImage imageNamed:@"Frame 58ht.png"],
  254.                  [UIImage imageNamed:@"Frame 59ht.png"],
  255.                  [UIImage imageNamed:@"Frame 60ht.png"],
  256.                  [UIImage imageNamed:@"Frame 61ht.png"],
  257.                  [UIImage imageNamed:@"Frame 62ht.png"],
  258.                  [UIImage imageNamed:@"Frame 63ht.png"],
  259.                  [UIImage imageNamed:@"Frame 64ht.png"],
  260.                  [UIImage imageNamed:@"Frame 65ht.png"],
  261.                  [UIImage imageNamed:@"Frame 66ht.png"],
  262.                  [UIImage imageNamed:@"Frame 67ht.png"],
  263.                  [UIImage imageNamed:@"Frame 68ht.png"],
  264.                  [UIImage imageNamed:@"Frame 69ht.png"],
  265.                  [UIImage imageNamed:@"Frame 70ht.png"],
  266.                  [UIImage imageNamed:@"Frame 71ht.png"],
  267.                  [UIImage imageNamed:@"Frame 72ht.png"],
  268.                  [UIImage imageNamed:@"Frame 73ht.png"],
  269.                  [UIImage imageNamed:@"Frame 74ht.png"],
  270.                  [UIImage imageNamed:@"Frame 75ht.png"],
  271.                  [UIImage imageNamed:@"Frame 76ht.png"],
  272.                  [UIImage imageNamed:@"Frame 77ht.png"],
  273.                  [UIImage imageNamed:@"Frame 78ht.png"],
  274.                  [UIImage imageNamed:@"Frame 79ht.png"],
  275.                  [UIImage imageNamed:@"Frame 80ht.png"],
  276.                  [UIImage imageNamed:@"Frame 81ht.png"],
  277.                  [UIImage imageNamed:@"Frame 82ht.png"],
  278.                  [UIImage imageNamed:@"Frame 83ht.png"],
  279.                  [UIImage imageNamed:@"Frame 84ht.png"],
  280.                  [UIImage imageNamed:@"Frame 85ht.png"],
  281.                  [UIImage imageNamed:@"Frame 86ht.png"],
  282.                  [UIImage imageNamed:@"Frame 87ht.png"],
  283.                  [UIImage imageNamed:@"Frame 88ht.png"],
  284.                  [UIImage imageNamed:@"Frame 89ht.png"],
  285.                  [UIImage imageNamed:@"Frame 90ht.png"], // 89th : 90 Total
  286.                  nil
  287.                  ];
  288.    
  289.    
  290.    
  291.    
  292.     headsHeads =[[NSMutableArray alloc] initWithObjects:
  293.                  [UIImage imageNamed:@"Frame 1hh.png"],  // 0
  294.                  [UIImage imageNamed:@"Frame 2hh.png"],
  295.                  [UIImage imageNamed:@"Frame 3hh.png"],
  296.                  [UIImage imageNamed:@"Frame 4hh.png"],
  297.                  [UIImage imageNamed:@"Frame 5hh.png"],
  298.                  [UIImage imageNamed:@"Frame 6hh.png"],
  299.                  [UIImage imageNamed:@"Frame 7hh.png"],
  300.                  [UIImage imageNamed:@"Frame 8hh.png"],
  301.                  [UIImage imageNamed:@"Frame 9hh.png"],
  302.                  [UIImage imageNamed:@"Frame 10hh.png"],
  303.                  [UIImage imageNamed:@"Frame 11hh.png"],
  304.                  [UIImage imageNamed:@"Frame 12hh.png"],
  305.                  [UIImage imageNamed:@"Frame 13hh.png"],
  306.                  [UIImage imageNamed:@"Frame 14hh.png"],
  307.                  [UIImage imageNamed:@"Frame 15hh.png"],
  308.                  [UIImage imageNamed:@"Frame 16hh.png"],
  309.                  [UIImage imageNamed:@"Frame 17hh.png"],
  310.                  [UIImage imageNamed:@"Frame 18hh.png"],
  311.                  [UIImage imageNamed:@"Frame 19hh.png"],
  312.                  [UIImage imageNamed:@"Frame 20hh.png"],
  313.                  [UIImage imageNamed:@"Frame 21hh.png"],
  314.                  [UIImage imageNamed:@"Frame 22hh.png"],
  315.                  [UIImage imageNamed:@"Frame 23hh.png"],
  316.                  [UIImage imageNamed:@"Frame 24hh.png"],
  317.                  [UIImage imageNamed:@"Frame 25hh.png"],
  318.                  [UIImage imageNamed:@"Frame 26hh.png"],
  319.                  [UIImage imageNamed:@"Frame 27hh.png"],
  320.                  [UIImage imageNamed:@"Frame 28hh.png"],
  321.                  [UIImage imageNamed:@"Frame 29hh.png"],
  322.                  [UIImage imageNamed:@"Frame 30hh.png"],
  323.                  [UIImage imageNamed:@"Frame 31hh.png"],
  324.                  [UIImage imageNamed:@"Frame 32hh.png"],
  325.                  [UIImage imageNamed:@"Frame 33hh.png"],
  326.                  [UIImage imageNamed:@"Frame 34hh.png"],
  327.                  [UIImage imageNamed:@"Frame 35hh.png"],
  328.                  [UIImage imageNamed:@"Frame 36hh.png"],
  329.                  [UIImage imageNamed:@"Frame 37hh.png"],
  330.                  [UIImage imageNamed:@"Frame 38hh.png"],
  331.                  [UIImage imageNamed:@"Frame 39hh.png"],
  332.                  [UIImage imageNamed:@"Frame 40hh.png"],
  333.                  [UIImage imageNamed:@"Frame 41hh.png"],
  334.                  [UIImage imageNamed:@"Frame 42hh.png"],
  335.                  [UIImage imageNamed:@"Frame 43hh.png"],
  336.                  [UIImage imageNamed:@"Frame 44hh.png"],
  337.                  [UIImage imageNamed:@"Frame 45hh.png"],
  338.                  [UIImage imageNamed:@"Frame 46hh.png"],
  339.                  [UIImage imageNamed:@"Frame 47hh.png"],
  340.                  [UIImage imageNamed:@"Frame 48hh.png"],
  341.                  [UIImage imageNamed:@"Frame 49hh.png"],
  342.                  [UIImage imageNamed:@"Frame 50hh.png"],
  343.                  [UIImage imageNamed:@"Frame 51hh.png"],
  344.                  [UIImage imageNamed:@"Frame 52hh.png"],
  345.                  [UIImage imageNamed:@"Frame 53hh.png"],
  346.                  [UIImage imageNamed:@"Frame 54hh.png"],
  347.                  [UIImage imageNamed:@"Frame 55hh.png"],
  348.                  [UIImage imageNamed:@"Frame 56hh.png"],
  349.                  [UIImage imageNamed:@"Frame 57hh.png"],
  350.                  [UIImage imageNamed:@"Frame 58hh.png"],
  351.                  [UIImage imageNamed:@"Frame 59hh.png"],
  352.                  [UIImage imageNamed:@"Frame 60hh.png"],
  353.                  [UIImage imageNamed:@"Frame 61hh.png"],
  354.                  [UIImage imageNamed:@"Frame 62hh.png"],
  355.                  [UIImage imageNamed:@"Frame 63hh.png"],
  356.                  [UIImage imageNamed:@"Frame 64hh.png"],
  357.                  [UIImage imageNamed:@"Frame 65hh.png"],
  358.                  [UIImage imageNamed:@"Frame 66hh.png"],
  359.                  [UIImage imageNamed:@"Frame 67hh.png"],
  360.                  [UIImage imageNamed:@"Frame 68hh.png"],
  361.                  [UIImage imageNamed:@"Frame 69hh.png"],
  362.                  [UIImage imageNamed:@"Frame 70hh.png"],
  363.                  [UIImage imageNamed:@"Frame 71hh.png"],
  364.                  [UIImage imageNamed:@"Frame 72hh.png"],
  365.                  [UIImage imageNamed:@"Frame 73hh.png"],
  366.                  [UIImage imageNamed:@"Frame 74hh.png"],
  367.                  [UIImage imageNamed:@"Frame 75hh.png"],
  368.                  [UIImage imageNamed:@"Frame 76hh.png"],
  369.                  [UIImage imageNamed:@"Frame 77hh.png"],
  370.                  [UIImage imageNamed:@"Frame 78hh.png"],
  371.                  [UIImage imageNamed:@"Frame 79hh.png"],
  372.                  [UIImage imageNamed:@"Frame 80hh.png"],
  373.                  [UIImage imageNamed:@"Frame 81hh.png"],
  374.                  [UIImage imageNamed:@"Frame 82hh.png"],
  375.                  [UIImage imageNamed:@"Frame 83hh.png"],
  376.                  [UIImage imageNamed:@"Frame 84hh.png"],
  377.                  [UIImage imageNamed:@"Frame 85hh.png"],
  378.                  [UIImage imageNamed:@"Frame 86hh.png"],
  379.                  [UIImage imageNamed:@"Frame 87hh.png"],
  380.                  [UIImage imageNamed:@"Frame 88hh.png"],
  381.                  [UIImage imageNamed:@"Frame 89hh.png"],
  382.                  [UIImage imageNamed:@"Frame 90hh.png"],
  383.                  [UIImage imageNamed:@"Frame 91hh.png"],
  384.                  [UIImage imageNamed:@"Frame 92hh.png"],
  385.                  [UIImage imageNamed:@"Frame 93hh.png"],
  386.                  [UIImage imageNamed:@"Frame 94hh.png"],
  387.                  [UIImage imageNamed:@"Frame 95hh.png"],
  388.                  [UIImage imageNamed:@"Frame 96hh.png"],
  389.                  [UIImage imageNamed:@"Frame 97hh.png"],
  390.                  [UIImage imageNamed:@"Frame 98hh.png"],
  391.                  nil
  392.                  ];
  393.    
  394.    
  395.     tailsTails =[[NSMutableArray alloc] initWithObjects:
  396.                  
  397.                  [UIImage imageNamed:@"Frame 1tt.png"],  // 0
  398.                  [UIImage imageNamed:@"Frame 2tt.png"],
  399.                  [UIImage imageNamed:@"Frame 3tt.png"],
  400.                  [UIImage imageNamed:@"Frame 4tt.png"],
  401.                  [UIImage imageNamed:@"Frame 5tt.png"],
  402.                  [UIImage imageNamed:@"Frame 6tt.png"],
  403.                  [UIImage imageNamed:@"Frame 7tt.png"],
  404.                  [UIImage imageNamed:@"Frame 8tt.png"],
  405.                  [UIImage imageNamed:@"Frame 9tt.png"],
  406.                  [UIImage imageNamed:@"Frame 10tt.png"],
  407.                  [UIImage imageNamed:@"Frame 11tt.png"],
  408.                  [UIImage imageNamed:@"Frame 12tt.png"],
  409.                  [UIImage imageNamed:@"Frame 13tt.png"],
  410.                  [UIImage imageNamed:@"Frame 14tt.png"],
  411.                  [UIImage imageNamed:@"Frame 15tt.png"],
  412.                  [UIImage imageNamed:@"Frame 16tt.png"],
  413.                  [UIImage imageNamed:@"Frame 17tt.png"],
  414.                  [UIImage imageNamed:@"Frame 18tt.png"],
  415.                  [UIImage imageNamed:@"Frame 19tt.png"],
  416.                  [UIImage imageNamed:@"Frame 20tt.png"],
  417.                  [UIImage imageNamed:@"Frame 21tt.png"],
  418.                  [UIImage imageNamed:@"Frame 22tt.png"],
  419.                  [UIImage imageNamed:@"Frame 23tt.png"],
  420.                  [UIImage imageNamed:@"Frame 24tt.png"],
  421.                  [UIImage imageNamed:@"Frame 25tt.png"],
  422.                  [UIImage imageNamed:@"Frame 26tt.png"],
  423.                  [UIImage imageNamed:@"Frame 27tt.png"],
  424.                  [UIImage imageNamed:@"Frame 28tt.png"],
  425.                  [UIImage imageNamed:@"Frame 29tt.png"],
  426.                  [UIImage imageNamed:@"Frame 30tt.png"],
  427.                  [UIImage imageNamed:@"Frame 31tt.png"],
  428.                  [UIImage imageNamed:@"Frame 32tt.png"],
  429.                  [UIImage imageNamed:@"Frame 33tt.png"],
  430.                  [UIImage imageNamed:@"Frame 34tt.png"],
  431.                  [UIImage imageNamed:@"Frame 35tt.png"], // fixed
  432.                  [UIImage imageNamed:@"Frame 36tt.png"],
  433.                  [UIImage imageNamed:@"Frame 37tt.png"],
  434.                  [UIImage imageNamed:@"Frame 38tt.png"],
  435.                  [UIImage imageNamed:@"Frame 39tt.png"],
  436.                  [UIImage imageNamed:@"Frame 40tt.png"],
  437.                  [UIImage imageNamed:@"Frame 41tt.png"],
  438.                  [UIImage imageNamed:@"Frame 42tt.png"],
  439.                  [UIImage imageNamed:@"Frame 43tt.png"],
  440.                  [UIImage imageNamed:@"Frame 44tt.png"],
  441.                  [UIImage imageNamed:@"Frame 45tt.png"],
  442.                  [UIImage imageNamed:@"Frame 46tt.png"],
  443.                  [UIImage imageNamed:@"Frame 47tt.png"],
  444.                  [UIImage imageNamed:@"Frame 48tt.png"],
  445.                  [UIImage imageNamed:@"Frame 49tt.png"],
  446.                  [UIImage imageNamed:@"Frame 50tt.png"],
  447.                  [UIImage imageNamed:@"Frame 51tt.png"],
  448.                  [UIImage imageNamed:@"Frame 52tt.png"],
  449.                  [UIImage imageNamed:@"Frame 53tt.png"],
  450.                  [UIImage imageNamed:@"Frame 54tt.png"],
  451.                  [UIImage imageNamed:@"Frame 55tt.png"],
  452.                  [UIImage imageNamed:@"Frame 56tt.png"],
  453.                  [UIImage imageNamed:@"Frame 57tt.png"],
  454.                  [UIImage imageNamed:@"Frame 58tt.png"],
  455.                  [UIImage imageNamed:@"Frame 59tt.png"],
  456.                  [UIImage imageNamed:@"Frame 60tt.png"],
  457.                  [UIImage imageNamed:@"Frame 61tt.png"],
  458.                  [UIImage imageNamed:@"Frame 62tt.png"],
  459.                  [UIImage imageNamed:@"Frame 63tt.png"],
  460.                  [UIImage imageNamed:@"Frame 64tt.png"],
  461.                  [UIImage imageNamed:@"Frame 65tt.png"],
  462.                  [UIImage imageNamed:@"Frame 66tt.png"], //fixed
  463.                  [UIImage imageNamed:@"Frame 67tt.png"],
  464.                  [UIImage imageNamed:@"Frame 68tt.png"],
  465.                  [UIImage imageNamed:@"Frame 69tt.png"],
  466.                  [UIImage imageNamed:@"Frame 70tt.png"],
  467.                  [UIImage imageNamed:@"Frame 71tt.png"],
  468.                  [UIImage imageNamed:@"Frame 72tt.png"],
  469.                  [UIImage imageNamed:@"Frame 73tt.png"],
  470.                  [UIImage imageNamed:@"Frame 74tt.png"],
  471.                  [UIImage imageNamed:@"Frame 75tt.png"],
  472.                  [UIImage imageNamed:@"Frame 76tt.png"],
  473.                  [UIImage imageNamed:@"Frame 77tt.png"],
  474.                  [UIImage imageNamed:@"Frame 78tt.png"],
  475.                  [UIImage imageNamed:@"Frame 79tt.png"],
  476.                  [UIImage imageNamed:@"Frame 80tt.png"],
  477.                  [UIImage imageNamed:@"Frame 81tt.png"],
  478.                  [UIImage imageNamed:@"Frame 82tt.png"],
  479.                  [UIImage imageNamed:@"Frame 83tt.png"],
  480.                  
  481.                  nil
  482.                  ];
  483.    
  484.    
  485.    
  486.    
  487.     tailsHeads = [[NSMutableArray alloc] initWithObjects:
  488.                  
  489.                  [UIImage imageNamed:@"Frame 1th.png"],   // 273 th start
  490.                  [UIImage imageNamed:@"Frame 2th.png"],
  491.                  [UIImage imageNamed:@"Frame 3th.png"],
  492.                  [UIImage imageNamed:@"Frame 4th.png"],
  493.                  [UIImage imageNamed:@"Frame 5th.png"],
  494.                  [UIImage imageNamed:@"Frame 6th.png"],
  495.                  [UIImage imageNamed:@"Frame 7th.png"],
  496.                  [UIImage imageNamed:@"Frame 8th.png"],
  497.                  [UIImage imageNamed:@"Frame 9th.png"],
  498.                  [UIImage imageNamed:@"Frame 10th.png"],
  499.                  [UIImage imageNamed:@"Frame 11th.png"],
  500.                  [UIImage imageNamed:@"Frame 12th.png"],
  501.                  [UIImage imageNamed:@"Frame 13th.png"],
  502.                  [UIImage imageNamed:@"Frame 14th.png"],
  503.                  [UIImage imageNamed:@"Frame 15th.png"],
  504.                  [UIImage imageNamed:@"Frame 16th.png"],
  505.                  [UIImage imageNamed:@"Frame 17th.png"],
  506.                  [UIImage imageNamed:@"Frame 18th.png"],
  507.                  [UIImage imageNamed:@"Frame 19th.png"],
  508.                  [UIImage imageNamed:@"Frame 20th.png"],
  509.                  [UIImage imageNamed:@"Frame 21th.png"],
  510.                  [UIImage imageNamed:@"Frame 22th.png"],
  511.                  [UIImage imageNamed:@"Frame 23th.png"],
  512.                  [UIImage imageNamed:@"Frame 24th.png"],
  513.                  [UIImage imageNamed:@"Frame 25th.png"],
  514.                  [UIImage imageNamed:@"Frame 26th.png"],
  515.                  [UIImage imageNamed:@"Frame 27th.png"],
  516.                  [UIImage imageNamed:@"Frame 28th.png"],
  517.                  [UIImage imageNamed:@"Frame 29th.png"],
  518.                  [UIImage imageNamed:@"Frame 30th.png"],
  519.                  [UIImage imageNamed:@"Frame 31th.png"],
  520.                  [UIImage imageNamed:@"Frame 32th.png"],
  521.                  [UIImage imageNamed:@"Frame 33th.png"],
  522.                  [UIImage imageNamed:@"Frame 34th.png"],
  523.                  [UIImage imageNamed:@"Frame 35th.png"], // fixed
  524.                  [UIImage imageNamed:@"Frame 36th.png"],
  525.                  [UIImage imageNamed:@"Frame 37th.png"],
  526.                  [UIImage imageNamed:@"Frame 38th.png"],
  527.                  [UIImage imageNamed:@"Frame 39th.png"],
  528.                  [UIImage imageNamed:@"Frame 40th.png"],
  529.                  [UIImage imageNamed:@"Frame 41th.png"],
  530.                  [UIImage imageNamed:@"Frame 42th.png"],
  531.                  [UIImage imageNamed:@"Frame 43th.png"],
  532.                  [UIImage imageNamed:@"Frame 44th.png"],
  533.                  [UIImage imageNamed:@"Frame 45th.png"],
  534.                  [UIImage imageNamed:@"Frame 46th.png"],
  535.                  [UIImage imageNamed:@"Frame 47th.png"],
  536.                  [UIImage imageNamed:@"Frame 48th.png"],
  537.                  [UIImage imageNamed:@"Frame 49th.png"],
  538.                  [UIImage imageNamed:@"Frame 50th.png"],
  539.                  [UIImage imageNamed:@"Frame 51th.png"],
  540.                  [UIImage imageNamed:@"Frame 52th.png"],
  541.                  [UIImage imageNamed:@"Frame 53th.png"],
  542.                  [UIImage imageNamed:@"Frame 54th.png"],
  543.                  [UIImage imageNamed:@"Frame 55th.png"],
  544.                  [UIImage imageNamed:@"Frame 56th.png"],
  545.                  [UIImage imageNamed:@"Frame 57th.png"],
  546.                  [UIImage imageNamed:@"Frame 58th.png"],
  547.                  [UIImage imageNamed:@"Frame 59th.png"],
  548.                  [UIImage imageNamed:@"Frame 60th.png"],
  549.                  [UIImage imageNamed:@"Frame 61th.png"],
  550.                  [UIImage imageNamed:@"Frame 62th.png"],
  551.                  [UIImage imageNamed:@"Frame 63th.png"],
  552.                  [UIImage imageNamed:@"Frame 64th.png"],
  553.                  [UIImage imageNamed:@"Frame 65th.png"],
  554.                  [UIImage imageNamed:@"Frame 66th.png"],
  555.                  [UIImage imageNamed:@"Frame 67th.png"],
  556.                  [UIImage imageNamed:@"Frame 68th.png"],
  557.                  [UIImage imageNamed:@"Frame 69th.png"],
  558.                  [UIImage imageNamed:@"Frame 70th.png"],
  559.                  [UIImage imageNamed:@"Frame 71th.png"],
  560.                  [UIImage imageNamed:@"Frame 72th.png"],
  561.                  [UIImage imageNamed:@"Frame 73th.png"],
  562.                  [UIImage imageNamed:@"Frame 74th.png"],
  563.                  [UIImage imageNamed:@"Frame 75th.png"],
  564.                  [UIImage imageNamed:@"Frame 76th.png"],
  565.                  [UIImage imageNamed:@"Frame 77th.png"],
  566.                  [UIImage imageNamed:@"Frame 78th.png"],
  567.                  [UIImage imageNamed:@"Frame 79th.png"],
  568.                  [UIImage imageNamed:@"Frame 80th.png"],
  569.                  [UIImage imageNamed:@"Frame 81th.png"],
  570.                  [UIImage imageNamed:@"Frame 82th.png"],
  571.                  [UIImage imageNamed:@"Frame 83th.png"],
  572.                  [UIImage imageNamed:@"Frame 84th.png"],
  573.                  [UIImage imageNamed:@"Frame 85th.png"],
  574.                  [UIImage imageNamed:@"Frame 86th.png"],
  575.                  [UIImage imageNamed:@"Frame 87th.png"],
  576.                  [UIImage imageNamed:@"Frame 88th.png"],
  577.                  [UIImage imageNamed:@"Frame 89th.png"],
  578.                  [UIImage imageNamed:@"Frame 90th.png"],
  579.                  [UIImage imageNamed:@"Frame 91th.png"],
  580.                  [UIImage imageNamed:@"Frame 92th.png"],
  581.                  nil
  582.                  ];
  583.    
  584.    
  585.     NSLog(@"Finshised Loading . .. ");
  586.     NSLog(@"[headsTails retainCount] = %i", [headsTails retainCount]);
  587.     NSLog(@"[headsHeads retainCount] = %i", [headsHeads retainCount]);
  588.     NSLog(@"[tailsTails retainCount] = %i", [tailsTails retainCount]);
  589.     NSLog(@"[tailsHeads retainCount] = %i", [tailsHeads retainCount]);
  590.     NSLog(@" ");
  591.    
  592. }
  593.  
  594. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  595. {
  596.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  597.  
  598.    
  599.     return self;
  600. }
  601.  
  602. - (void)didReceiveMemoryWarning
  603. {
  604.     // Releases the view if it doesn't have a superview.
  605.     [super didReceiveMemoryWarning];
  606.     // Release any cached data, images, etc that aren't in use.
  607. }
  608.  
  609. #pragma mark - View lifecycle
  610.  
  611. - (void)viewDidLoad
  612. {
  613.     [super viewDidLoad];
  614.     self.title = @"Coin Toss";
  615.     labelcount = 0; // resets the labels each time view is loaded
  616.    
  617.     // This is the same code that is in touches began, from here
  618.     // TO DO : put in a function.
  619.     initArrays = 1;
  620.     xCoin = 2;
  621.     r  = arc4random() % 2;   // will pick a 0 or a 1, assign it to r
  622.     r2 = arc4random() % 2;   // " for coin 2.
  623.     labelcount +=1;
  624.    
  625.    
  626.     [self callValueFromSelect];
  627.     [self fillArrays];
  628.     [self rollTheDice];
  629.     [startLabel setHidden:YES]; // hides the tap to begin, after one touch.
  630.     NSLog(@"IN VIEW DID LOAD");
  631.     NSLog(@"[coinOneA retainCount] = %i", [coinOneA retainCount]);
  632.     NSLog(@"[coinOneB retainCount] = %i", [coinOneB retainCount]);
  633.     NSLog(@"[coinOneC retainCount] = %i", [coinOneC retainCount]);
  634.     NSLog(@"[coinOneD retainCount] = %i", [coinOneD retainCount]);
  635.     NSLog(@"[coinOneE retainCount] = %i", [coinOneE retainCount]);
  636.     NSLog(@"[coinOneF retainCount] = %i", [coinOneF retainCount]);
  637.     NSLog(@"[coinOneG retainCount] = %i", [coinOneG retainCount]);
  638.     NSLog(@"[coinOneH retainCount] = %i", [coinOneH retainCount]);
  639.     NSLog(@"[coinOneI retainCount] = %i", [coinOneI retainCount]);
  640.     NSLog(@"[coinOneJ retainCount] = %i", [coinOneJ retainCount]);
  641.     NSLog(@" ");
  642. }
  643.  
  644. -(void) rollTheDice {
  645.    
  646.    
  647.     // **********************************
  648.     // **** Select Current Animation ****
  649.     // **********************************
  650.    
  651.     randAnimation = [[NSMutableArray alloc] init];  // coin 1
  652.     randAnimation2 = [[NSMutableArray alloc] init]; // coin 2
  653.    
  654.     // ************************* Coin ONE *********************************
  655.    
  656.     // H -> H
  657.     // last was heads, this is heads
  658.    
  659.    
  660.     if ((r==1) && (l==1)) {
  661.        
  662.         imageView.animationImages = headsHeads; // Coin 1
  663.         imageView.image = [headsHeads lastObject];               // NEW TACTICS HERE
  664.         l = 1;  // update last
  665.        
  666.         coinOneStringVal = @"H";    // set the label to be a H when printed
  667.     }
  668.    
  669.    
  670.     // H -> T
  671.     // last was heads ( l = 1), this is tails ( r = 0)
  672.     if ((r==0) && (l==1)) {
  673.        
  674.         imageView.animationImages= headsTails;  // Coin 1
  675.         imageView.image = [headsTails lastObject];               // NEW TACTICS HERE
  676.         l =0;   // update last
  677.        
  678.         coinOneStringVal = @"T";    // set the label to be a T when printed
  679.        
  680.     }
  681.    
  682.     // T -> H
  683.     // last was tails ( l = 0), this is heads ( r = 1)
  684.     if ((r==1) && (l==0)) {
  685.        
  686.        
  687.         imageView.animationImages= tailsHeads;  // Coin 1
  688.         imageView.image = [tailsHeads lastObject];               // NEW TACTICS HERE
  689.         l =1; // update last
  690.        
  691.         coinOneStringVal = @"H";    // set the label to be a H when printed
  692.     }
  693.    
  694.     // T -> T
  695.     // last was tails ( l =0), this is tails ( r = 0)
  696.    
  697.     if ((r==0) && (l==0)) {
  698.        
  699.         imageView.animationImages= tailsTails;  // Coin 1
  700.         imageView.image = [tailsTails lastObject];               // NEW TACTICS HERE
  701.         l = 0; // update last
  702.        
  703.         coinOneStringVal = @"T";    // set the label to be a H when printed
  704.        
  705.     }
  706.    
  707.     // ************************* Coin TWO *********************************
  708.    
  709.    
  710.     // H -> H
  711.     // last was heads, this is heads
  712.     if ((r2==1) && (l2==1)) {
  713.        
  714.         imageView2.animationImages = headsHeads;    // Coin 2
  715.         imageView2.image = [headsHeads lastObject];     // NEW TACTICS HERE
  716.         // TO KEEP IMAGE AT THE END
  717.         l2 = 1;  // update last
  718.         if (amountSelectedCoin == 0){
  719.             coinTwoStringVal = @"";
  720.         }
  721.         else coinTwoStringVal = @"H";    // set the label to be a H when printed
  722.        
  723.     }
  724.    
  725.    
  726.     // H -> T
  727.     // last was heads ( l2 = 1), this is tails ( r2 = 0)
  728.     if ((r2==0) && (l2==1)) {
  729.        
  730.         [randAnimation2 removeAllObjects];
  731.         for (i2 =0; i2 < headsTails.count; i2++) {
  732.             [randAnimation2 addObject:[headsTails objectAtIndex:i2]];
  733.         }
  734.         imageView2.animationImages= randAnimation2; // Coin 2
  735.         imageView2.image = [randAnimation2 lastObject];               // NEW TACTICS HERE
  736.         l2 =0;   // update last
  737.        
  738.         if (amountSelectedCoin == 0){
  739.             coinTwoStringVal = @"";
  740.         }
  741.         else coinTwoStringVal = @"T";    // set the label to be a H when printed
  742.        
  743.     }
  744.    
  745.     // T -> H
  746.     // last was tails ( l2 = 0), this is heads ( r2 = 1)
  747.     if ((r2==1) && (l2==0)) {
  748.        
  749.        
  750.        
  751.         imageView2.animationImages= tailsHeads; // Coin 2
  752.         imageView2.image = [tailsHeads lastObject];               // NEW TACTICS HERE
  753.         l2 =1; // update last
  754.        
  755.         if (amountSelectedCoin == 0){
  756.             coinTwoStringVal = @"";
  757.         }
  758.         else coinTwoStringVal = @"H";    // set the label to be a H when printed
  759.     }
  760.    
  761.     // T -> T
  762.     // last was tails ( l2 =0), this is tails ( r2 = 0)
  763.    
  764.     if ((r2==0) && (l2==0)) {
  765.        
  766.        
  767.         imageView2.animationImages= tailsTails; // Coin 2
  768.         imageView2.image = [tailsTails lastObject];               // NEW TACTICS HERE
  769.         l2 = 0; // update last
  770.        
  771.         if (amountSelectedCoin == 0){
  772.             coinTwoStringVal = @"";
  773.         }
  774.         else coinTwoStringVal = @"T";    // set the label to be a H when printed
  775.        
  776.     }
  777.    
  778.    
  779.    
  780.    
  781.    
  782.    
  783.     imageView.animationDuration=4// The duration for which the image is displayed on
  784.     imageView2.animationDuration=4; // The duration for which the image is displayed on
  785.    
  786.    
  787.    
  788.     imageView.animationRepeatCount = 1; // Animation only played once on each die
  789.     imageView2.animationRepeatCount = 1; // Animation only played once on each die
  790.    
  791.    
  792.     // The Switch Statement
  793.     // This decides on the amount of images to show
  794.    
  795.     if ( xCoin > 0) {       // if its not the first execution of the code
  796.        
  797.         switch(amountSelectedCoin)
  798.         {
  799.             case 0: // One Coin
  800.                 [imageView2 setHidden:YES]; // Hides the second coin
  801.                  
  802.                 [imageView startAnimating]; // when the roll button is pressed, this code is called
  803.                
  804.                 // Code to display label results after the coin animation is
  805.                 // finsihed.
  806.                 [self performSelector:@selector(updateLabels) withObject:nil afterDelay:imageView.animationDuration];
  807.                
  808.                 break;
  809.                
  810.             case 1: // Two Coins
  811.                 [imageView2 setHidden:NO];  // Unhide the 2nd Coin
  812.                
  813.                
  814.                 [imageView startAnimating]; // Execute coin 1 animation
  815.                 [imageView2 startAnimating];// Execute coin 2 animation
  816.                
  817.                 // Checks animation arrays are not empty at last object
  818.                
  819.                
  820.                 [self performSelector:@selector(updateLabels) withObject:nil afterDelay:imageView.animationDuration];
  821.                
  822.                
  823.                
  824.                
  825.                 break;
  826.                
  827.                
  828.         }}
  829. [randAnimation release];
  830. [randAnimation2 release];
  831.     NSLog(@"The second method counts :  ");
  832.     NSLog(@"[headsTails retainCount] = %i", [headsTails retainCount]);
  833.     NSLog(@"[headsHeads retainCount] = %i", [headsHeads retainCount]);
  834.     NSLog(@"[tailsTails retainCount] = %i", [tailsTails retainCount]);
  835.     NSLog(@"[tailsHeads retainCount] = %i", [tailsHeads retainCount]);
  836.     NSLog(@" ");
  837.     NSLog(@"Others");
  838.     NSLog(@"[toggleButton retainCount] = %i", [toggleButton retainCount]);
  839.     NSLog(@"[imageView retainCount] = %i", [imageView retainCount]);
  840.     NSLog(@"[imageView2 retainCount] = %i", [imageView2 retainCount]);
  841.     NSLog(@"[animationSpeed retainCount] = %i", [animationSpeed retainCount]);
  842.     NSLog(@"[coinOneA retainCount] = %i", [coinOneA retainCount]);
  843.     NSLog(@"[coinOneB retainCount] = %i", [coinOneB retainCount]);
  844.     NSLog(@"[coinOneC retainCount] = %i", [coinOneC retainCount]);
  845.     NSLog(@"[coinOneD retainCount] = %i", [coinOneD retainCount]);
  846.     NSLog(@"[coinOneE retainCount] = %i", [coinOneE retainCount]);
  847.     NSLog(@"[coinOneF retainCount] = %i", [coinOneF retainCount]);
  848.     NSLog(@"[coinOneG retainCount] = %i", [coinOneG retainCount]);
  849.     NSLog(@"[coinOneH retainCount] = %i", [coinOneH retainCount]);
  850.     NSLog(@"[coinOneI retainCount] = %i", [coinOneI retainCount]);
  851.     NSLog(@"[coinOneJ retainCount] = %i", [coinOneJ retainCount]);
  852.    
  853.    
  854.    
  855.    
  856.    
  857. }
  858.  
  859.  
  860. //              **********     V E R Y       *********
  861. //              ********** I M P O R T A N T *********
  862. // function to call from the SelectCoinViewController class
  863. // then this fucntion should be called from the IBAction method above
  864.  
  865. -(void) callValueFromSelect {
  866.     SelectCoinViewController *instanceOfSelect = [[SelectCoinViewController alloc]init];
  867.     amountSelectedCoin = [instanceOfSelect returnSelection];
  868.     // testing for value of amountSelectedCoin
  869.     // prints to label
  870.     hopsPerSecond.text = [NSString  stringWithFormat:@"%i", amountSelectedCoin];
  871.     startLabel.text = @"Loading . . .";
  872.     [instanceOfSelect release];
  873. }
  874.  
  875. - (void)viewDidUnload
  876. {
  877.    
  878.     self.toggleButton = nil;
  879.     self.imageView = nil;
  880.     self.imageView2 = nil;
  881.     self.animationSpeed = nil;
  882.     self.hopsPerSecond = nil;
  883.     self.startLabel = nil;    
  884.     self.coinOneA = nil;
  885.     self.coinOneB = nil;
  886.     self.coinOneC = nil;
  887.     self.coinOneD = nil;
  888.     self.coinOneE = nil;
  889.     self.coinOneF = nil;
  890.     self.coinOneG = nil;
  891.     self.coinOneH = nil;
  892.     self.coinOneI = nil;
  893.     self.coinOneJ = nil;
  894.     self.coinTwoA = nil;
  895.     self.coinTwoB = nil;
  896.     self.coinTwoC = nil;
  897.     self.coinTwoD = nil;
  898.     self.coinTwoE = nil;
  899.     self.coinTwoF = nil;
  900.     self.coinTwoG = nil;
  901.     self.coinTwoH = nil;
  902.     self.coinTwoI = nil;
  903.     self.coinTwoJ = nil;
  904.  
  905.     [super viewDidUnload];
  906.  
  907.  
  908.     // Release any retained subviews of the main view.
  909.     // e.g. self.myOutlet = nil;
  910. }
  911.  
  912. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  913. {
  914.     // Return YES for supported orientations
  915.     return (interfaceOrientation == UIInterfaceOrientationPortrait);
  916. }
  917.  
  918. - (void)dealloc {
  919.    
  920.     [toggleButton release];
  921.     [imageView release];
  922.     [imageView2 release];
  923.     [animationSpeed release];
  924.     [hopsPerSecond release];
  925.    
  926.     [coinOneA release];
  927.     [coinOneB release];
  928.     [coinOneC release];
  929.     [coinOneD release];
  930.     [coinOneE release];
  931.     [coinOneF release];
  932.     [coinOneG release];
  933.     [coinOneH release];
  934.     [coinOneI release];
  935.     [coinOneJ release];
  936.    
  937.     [coinTwoA release];
  938.     [coinTwoB release];
  939.     [coinTwoC release];
  940.     [coinTwoD release];
  941.     [coinTwoE release];
  942.     [coinTwoF release];
  943.     [coinTwoG release];
  944.     [coinTwoH release];
  945.     [coinTwoI release];
  946.     [coinTwoJ release];
  947.    
  948.    
  949.     [headsTails release];
  950.     [headsHeads release];
  951.     [tailsHeads release];
  952.     [tailsTails release];
  953.  
  954.      
  955.     [super dealloc];
  956.    
  957.     // note the arrays headsHeads etc. are not being released anywhere at the moment
  958. }
  959.  
  960.  
  961. // This code calls is the same as the button call,
  962. // is is used anytime the view is touched.
  963. // Touch is enabled.
  964. #pragma mark -
  965. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  966.    
  967.     self.view.userInteractionEnabled = NO; // disables user interaction after touch
  968.     // enable after update of label
  969.     initArrays = 1;
  970.     xCoin = 2;
  971.     r  = arc4random() % 2;   // will pick a 0 or a 1, assign it to r
  972.     r2 = arc4random() % 2;   // " for coin 2.
  973.     labelcount +=1;
  974.    
  975.    
  976.     [self callValueFromSelect];
  977.     [self fillArrays];
  978.     [self rollTheDice];
  979.     [startLabel setHidden:YES]; // hides the tap to begin, after one touch.
  980. }
  981.  
  982. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement