Looking for a little tiny help

Discussion in 'iOS Development' started by JoshuaCaputo, Feb 8, 2009.

  1. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Just post your question here. Arrays are easy.
  3. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    I feel really bad asking you though. You've helped me so much and I still remain asking the same question a month later.

    Basically I want to have a bunch of images to fall from the top to the bottom which I have accomplished.

    Code:
    UIImageView* flakeView = [[UIImageView alloc] initWithImage:falling];
    	
    	// use the random() function to randomize up our flake attributes
    	int startX = round(random() % 480);
    	int endX = startX;
    	double speed =  1 / round(random() % 100) + 1.0;
    	double scale = round(random() % 25) + 1.0;
    	
    	// set the flake start position
    	flakeView.frame = CGRectMake(startX, -100, 49 + scale, 49 + scale);
    	flakeView.alpha = 1;
    	
    	// put the flake in our main view
    	[self.view addSubview:flakeView];
    	
    	[UIView beginAnimations:nil context:flakeView];
    	// set up how fast the flake will fall
    	[UIView setAnimationDuration:5 * speed];
    	
    	// set the postion where flake will move to
    	flakeView.frame = CGRectMake(endX, 420, 49 + scale, 49 + scale);
    	
    	// set a stop callback so we can cleanup the flake when it reaches the
    	// end of its animation
    	[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
    	[UIView setAnimationDelegate:self];
    	[UIView commitAnimations];
    
    
    But the problem I have been having for months it how to have those images know where they are.

    So if it crosses the same (x,y) as another image it functions;

    I have tried to implement your suggestions,

    Code:
    	UIImageView *imageView[100];
    	int i = 0;
    	for (i = 0; i <= 99; i++){
    		imageView[i] = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"char1.png"]] autorelease];
    	}
    	//Refer to your images with a variable, or a static int, starting with 0
    	//imageView[1]...  imageView[54]... imageView[x]... etc.
    but when I try and do something like:
    Code:
    	imageView[1].center = CGPointMake(imageView[1].center.x+personPos.x,imageView[1].center.y+personPos.y);
    
    it doesn't work right.

    Sorry if thats confusing but thats my problem.

Share This Page