Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Transforms are not accumulative e.g. each transform operates on the original matrix and not the matrix returned by the last transform. That is why you <code>image1</code> object transform once and then stays there. It is the exact same transform starting at the beginning over and over again. </p> <p>Instead of trying to accumulate or sum the transforms, you need to accumulate or sum the <code>scale</code> variable. Make the <code>scale</code> variable a property of the controller object that holds the method and then progressively increment the value to make <code>image1</code> larger.</p> <p>Something like:</p> <pre><code>-(void)collision { if(CGRectIntersectsRect(imageView.frame,centre.frame)){ self.scale=self.scale+1; // scale is no longer a local value and will increment imageView.alpha=0.5; [imageView removeFromSuperview]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0f]; centre.transform = CGAffineTransformScale(centre.transform, scale, scale); [UIView commitAnimations]; } } </code></pre> <h2>Update:</h2> <p>To convert a local variable i.e. one defined in a single method, you move the definition to header (.h) file like so:</p> <pre><code>@implementation MyViewController:NSViewController{ //... various definitions } @property NSInteger *scale; </code></pre> <p>... then in the implementation file (.m) add the synthesize directive:</p> <pre><code>@synthesize scale; </code></pre> <p>Now you can use <code>self.scale</code> to refer to <code>scale</code> property anywhere in the class and it will be preserved. Each time you call:</p> <pre><code>self.scale=self.scale + 1; </code></pre> <p>... the value will increment and will be saved so that it is available for the next collision. </p> <p>Each time you call <code>collision</code> the scale value will change by one e.g.</p> <pre><code>centre.transform = CGAffineTransformScale(centre.transform, 1, 1); ... centre.transform = CGAffineTransformScale(centre.transform, 2, 2); .... centre.transform = CGAffineTransformScale(centre.transform, 3, 3); //... and so on </code></pre> <p>... the <code>CGAffineTransformScale</code> will increasing transform the imageview to a large size.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload