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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-29-2010, 04:27 PM   #9 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Post

Excellent. The "continue" is a command you can use inside loops to skip to the next iteration of the loop; the rest of the loop after "continue" is skipped for this block.

When a block hits the bottom you can add it to a different array - maybe called stoppedBlocks. It'll have to be an instance variable like blockArray, and you'll have to init it somewhere.
Code:
    if (newCenter.y > 420) {
           [stoppedBlocks addObject: block];
           [self addOneBlock];
           continue;
    }

//more moveBlocks stuff

//at the end of moveBlocks, remove all stoppedBlocks from the blockArray 
[blockArray removeObjectsInArray:stoppedBlocks];
}
You'll also have to write the method createOneBlock to create one new block. it'll look a lot like createBlocks, but without the loop.

Note this still won't make blocks stop when they hit other blocks, that'll have to wait until this is working.

Edit: I just realized that it'll crash when you try to add a block to the array while still looping through it. Post your moveBlocks code after you add this code, and I'll fix the loop so you can add blocks while looping.
__________________

Free Games!

Last edited by smasher; 01-29-2010 at 06:53 PM.
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 272
23 members and 249 guests
ADY, aikhan, AppAnnex, astalavista, chemistry, fkmtc, HemiMG, her-ur, ilmman, leahov, MarkC, marto1914, mer10, nicko, padsoftware, pavanindira, Raffaello, sneaky, syver, tathaastu, timle8n1, touchcream, ziocleto
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,219
Posts: 380,710
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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