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

View Single Post
Old 02-09-2010, 02:07 PM   #40 (permalink)
iPhoneDevelopment
Banned
 
Join Date: Dec 2009
Posts: 61
iPhoneDevelopment is on a distinguished road
Default

A search through the forum yielded an earlier post from you to detect if an object was above another object. I have adapted it, and it works for the blocks in my blockArray. I cannot get it, however, to work with my stoppedBlocks array at the same time. Here is it at the moment:
Code:
for (UIImageView *block in blockArray) {
	for (UIImageView *block in stoppedBlocks) {
		float charBottom = (character.frame.origin.y + character.frame.size.height);
		float blockTop = block.frame.origin.y;
		float heightAboveBlock = blockTop - charBottom;
		
		bool onTop = heightAboveBlock <10  //char is a little above the top of the box
		&& heightAboveBlock >-10  //or a little below the top of the box
		&& character.center.x > block.frame.origin.x //x is greater than left side
		&& character.center.x < block.frame.origin.x + block.frame.size.width; //x is less than right side
		
		if (onTop){
			character.frame = CGRectMake(character.frame.origin.x, blockTop-character.frame.size.height,
										 character.frame.size.width, character.frame.size.height);
			ySpeed +=0;
		} } }
How do I get it to work for both arrays?

(I have given up with the notion of hitting blocks from the sides and bottom for two reasons: 1) it would make the game incredibly hard to play 2) it would have been quite difficult to achieve :P)

Thanks

Cam
iPhoneDevelopment is offline   Reply With Quote
 

» Advertisements
» Online Users: 532
13 members and 519 guests
Adamz3us, alexP, blackcat_tq, chemistry, diannjp49, Domele, ilmman, kieshatx65, lzwasyc, nebulabox, nguyenhieu129, Punkjumper, Son of a Beach
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,447
Threads: 94,031
Posts: 402,606
Top Poster: BrianSlick (7,978)
Welcome to our newest member, diannjp49
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:59 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.