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 03-17-2009, 10:54 PM   #4 (permalink)
rhfb
Registered Member
 
Join Date: Mar 2009
Posts: 29
rhfb is on a distinguished road
Default

I don't understand exactly what the brickArray is referring to. Code to create an array of int values looks like this (again, I think... very rusty on C and new to Obj-C)

Code:
int brickLayout[8][8] = {
	{0,0,0,0,0,0,0,0},
	{1,1,0,0,0,0,1,1},
	{1,0,1,0,0,1,0,1},
	{1,0,2,0,0,2,0,1},
	{1,0,2,0,0,2,0,1},
	{1,0,1,0,0,1,0,1},
	{1,1,0,0,0,0,1,1},
	{1,1,3,1,1,3,1,1}
};
Then you index into the array by using your i value in the same way you assigned the position.

Code:
int thisBrickValue = brickLayout[i%8][i/8];
Though you may have to switch the values if things start to look funky. Or it may be perfectly fine, just kinda strange to me because I'm used to row major ordered arrays and not column major ordered.

Using the value you get from the array you can then use a switch statement to create the correct image.

Code:
switch(thisBrickValue) {
    case 1:
        brick = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"yellow.png"]]];
        break;
    case 2:
        brick = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"blue.png"]]];
        break;
//ECT ECT ECT
    default:
        NSLog(@"ERROR!!!");
}
Hope this code helps you to get it up and running, if not just reply and I'll try to help some more.
rhfb is offline   Reply With Quote
 

» Advertisements
» Online Users: 469
19 members and 450 guests
apatsufas, baja_yu, buggen, chenpo, ChrisYates, Feldspar, HowEver, ilmman, IphoneSdk, jbro, jeroenkeij, jNoxx, RobTaku, rraagg, samdanielblr, swelsh, taylor202, Trickphotostudios, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,636
Threads: 94,098
Posts: 402,804
Top Poster: BrianSlick (7,990)
Welcome to our newest member, samdanielblr
Powered by vBadvanced CMPS v3.1.0

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