Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-19-2010, 03:57 PM   #1 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Question moving an image

Hi, I am trying to figure how I could move an image with your finger around the screen. Can you make it so you can drag the image and watch for collisions or do you have to set it so the image follows where your finger goes and check for collisions that way? If someone knows any good way of doing this would be helpful.

Also, I have an app currently 'waiting for review',is changing the price and launch date going to place it back into the beginning of the queue. If not what are the only things that will place it back at the beginning of the queue, I know taking out the binary does.
__________________


Counting Time Now on the appstore - a very addicting strategic time game!!
http://itunes.apple.com/us/app/count...377631631?mt=8
Mjsdabeast is offline   Reply With Quote
Old 06-19-2010, 11:21 PM   #2 (permalink)
Eager to Learn Member
iPhone Dev SDK Supporter
 
mkenney's Avatar
 
Join Date: Sep 2009
Posts: 76
mkenney is on a distinguished road
Default

Check out the touchesMoved for what you are looking to do.
Code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	
	UITouch *touch = [touches anyObject];
	CGPoint currentPosition = [touch locationInView:self.view];
}
You can then move your UIImageView around and run some collision tests if you want to as well. I know its not the answer but might be the direction??
mkenney is offline   Reply With Quote
Old 06-20-2010, 11:18 AM   #3 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by mkenney View Post
Check out the touchesMoved for what you are looking to do.
Code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	
	UITouch *touch = [touches anyObject];
	CGPoint currentPosition = [touch locationInView:self.view];
}
You can then move your UIImageView around and run some collision tests if you want to as well. I know its not the answer but might be the direction??
Ok, that seems to work well for moving the image around the screen, but i want to have another image fall from the screen randomly and have it check for collisions, but it's not working, if you or anyone else knows how i could have the one image animate down the screen while checking for collisions. That would be great
__________________


Counting Time Now on the appstore - a very addicting strategic time game!!
http://itunes.apple.com/us/app/count...377631631?mt=8
Mjsdabeast is offline   Reply With Quote
Old 06-20-2010, 11:37 AM   #4 (permalink)
Eager to Learn Member
iPhone Dev SDK Supporter
 
mkenney's Avatar
 
Join Date: Sep 2009
Posts: 76
mkenney is on a distinguished road
Default

Quote:
Originally Posted by Mjsdabeast View Post
Ok, that seems to work well for moving the image around the screen, but i want to have another image fall from the screen randomly and have it check for collisions, but it's not working, if you or anyone else knows how i could have the one image animate down the screen while checking for collisions. That would be great
check out NSTimer and CGRectIntersectsRect for a simple start to this. The NSTimer will let you fire a method that moves the object from the top of the screen and then you could use the CGRectIntersectsRect within both that method and the touchesMoved method to do some simple collision testing. Not the best in the world but a nice start to get the concept...

Hope this helps!
mkenney is offline   Reply With Quote
Old 06-21-2010, 10:14 AM   #5 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by mkenney View Post
check out NSTimer and CGRectIntersectsRect for a simple start to this. The NSTimer will let you fire a method that moves the object from the top of the screen and then you could use the CGRectIntersectsRect within both that method and the touchesMoved method to do some simple collision testing. Not the best in the world but a nice start to get the concept...

Hope this helps!
I know I have that in my code(i'm not a complete noob), I have a timer running about every tenth of a second and each time that runs i want the images to continually move down the screen by about 5 pixels each time. But they're stopping after 5 pixels and they won't move again, only the new images created during that instance move. Here's my code if that helps:
Code:
-(void)gameLoopone {

	bigbomb = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bigbomb.png"]];
[self.view addSubview: bigbomb];


	    CGPoint position;

		positionX = arc4random() % 315;
		position.x = positionX;
		
		position.y = -5.0;

		bigbomb.center = position;
		
		[UIView beginAnimations:nil context:NULL];
		[UIView setAnimationDelegate:self];
		[UIView setAnimationDuration:.5];
		[UIView setAnimationBeginsFromCurrentState:YES];
		bigbomb.frame = CGRectMake(bigbomb.frame.origin.x, (bigbomb.frame.origin.y + 5.0), bigbomb.frame.size.width, bigbomb.frame.size.height);
		[UIView commitAnimations];
		NSLog(@"animating big bomb first level.");
		if (bigbomb.frame.origin.y >= 480.0) {
		//self.view = gameOver;
			NSLog(@"You lose");
			[bigbomb stopAnimating];
			[bigbomb removeFromSuperview];
			[bigbomb release];
		}
		
		if (CGRectIntersectsRect(bigbomb.frame,box.frame)) {
			score++;
		NSString *string = [[NSString alloc] initWithFormat:@"Score: %i", score];
			scoreLabel.text = string;
			[bigbomb removeFromSuperview];
		}
	
}
and here is the timer i am calling to run gameloopone:
Code:
timer1 = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(gameLoopone) userInfo:nil repeats:YES];
and if you're wondering here is how i made the image draggable:

Code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	
	touch = [touches anyObject];
	currentPosition = [touch locationInView:self.view];
	box.center = currentPosition;
	
}
__________________


Counting Time Now on the appstore - a very addicting strategic time game!!
http://itunes.apple.com/us/app/count...377631631?mt=8

Last edited by Mjsdabeast; 06-21-2010 at 10:16 AM.
Mjsdabeast is offline   Reply With Quote
Old 06-21-2010, 10:35 AM   #6 (permalink)
Registered Member
 
Join Date: Mar 2010
Age: 37
Posts: 72
ImpresionesWeb is on a distinguished road
Default

Quote:
Originally Posted by Mjsdabeast View Post
(i'm not a complete noob)....
Man, you, me and a lot other people are complete noobs, no need to feel ashamed about it.

So, for the code I think you have to add the UIImageViews in a NSMutableArray , you are overwriting your "bigbomb" everytime the timer runs the "gameLoopone".

THEN you have to loop for all the bombs with a: for (UIImageView* bombs in bombsArray) and update ALL the bombs positions, not just ONE as you do now.

Greetings
ImpresionesWeb is offline   Reply With Quote
Old 06-21-2010, 10:41 AM   #7 (permalink)
Registered Member
 
Join Date: Mar 2010
Age: 37
Posts: 72
ImpresionesWeb is on a distinguished road
Default

BTW with the code as you have it you are going to create 6 bombs every second.
I doubt that is what you really want, so I would create another NSTimer and another method to create the bombs and let the one you showed us to move them.
ImpresionesWeb is offline   Reply With Quote
Old 06-21-2010, 12:54 PM   #8 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by ImpresionesWeb View Post
Man, you, me and a lot other people are complete noobs, no need to feel ashamed about it.

So, for the code I think you have to add the UIImageViews in a NSMutableArray , you are overwriting your "bigbomb" everytime the timer runs the "gameLoopone".

THEN you have to loop for all the bombs with a: for (UIImageView* bombs in bombsArray) and update ALL the bombs positions, not just ONE as you do now.

Greetings
Ok, i've never worked with arrays, could you show me how to make one for this certain scenario, so that the animation loops through all the images of bigbomb on the screen. Thanks.
__________________


Counting Time Now on the appstore - a very addicting strategic time game!!
http://itunes.apple.com/us/app/count...377631631?mt=8
Mjsdabeast is offline   Reply With Quote
Old 06-21-2010, 12:59 PM   #9 (permalink)
Eager to Learn Member
iPhone Dev SDK Supporter
 
mkenney's Avatar
 
Join Date: Sep 2009
Posts: 76
mkenney is on a distinguished road
Thumbs up

Quote:
Originally Posted by Mjsdabeast View Post
I know I have that in my code(i'm not a complete noob)
Rodger, good luck!
mkenney is offline   Reply With Quote
Old 06-21-2010, 03:04 PM   #10 (permalink)
Registered Member
 
Join Date: Mar 2010
Age: 37
Posts: 72
ImpresionesWeb is on a distinguished road
Default

Quote:
Originally Posted by Mjsdabeast View Post
Ok, i've never worked with arrays, could you show me how to make one for this certain scenario, so that the animation loops through all the images of bigbomb on the screen. Thanks.
Just like mkeneey says: "Good luck"
I can point you in the right direction but I´m not going to work it for you. You are not a noob so look for it in apple tutorials.

Greetings
ImpresionesWeb is offline   Reply With Quote
Old 06-21-2010, 03:34 PM   #11 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by ImpresionesWeb View Post
Just like mkeneey says: "Good luck"
I can point you in the right direction but I´m not going to work it for you. You are not a noob so look for it in apple tutorials.

Greetings
Ok, that's fine.
__________________


Counting Time Now on the appstore - a very addicting strategic time game!!
http://itunes.apple.com/us/app/count...377631631?mt=8
Mjsdabeast is offline   Reply With Quote
Reply

Bookmarks

Tags
collision, image, moving, review, waiting

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 339
8 members and 331 guests
anothermine, Chickenrig, Domele, givensur, heshiming, michaelhansen, PixelInteractive, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0