- (void)initController {
srandom( abs( time( nil ) ) );
[self loadImages];
int x, y;
for ( y = 0; y < 6; y++ ) {
for ( x = 0; x < 6; x++ )
{
CGRect bounds = CGRectMake(0, 3, 50, 50 );
bounds = CGRectOffset( bounds, x * 54, y * 55);
CardView *button = [[[CardView alloc]
initWithFrame:bounds] autorelease];
[button setTarget:self];
[button setIndex:x + y * 6];
[view addSubview:button];
}
}
[model readScoreData];
[model setupCards:36];
[self syncModelToView];
5・7行目(line)
計36回ループさせたいので4を6に変更。
Method of loop 36 times in total.
9行目(line) X座標、Y座標、幅、高さを、変更。
直角4辺形の構造体の設定を行う。
Changing the X coordinates, Y coordinates, width, and height.
Setting of ectangular structure.
10行目(line)
変数boundsの原点の移動を表す。
9・10行目のメソッドで数字の調整をする必要がある。
図1は修正前。
This method shows movement an origin of bounds.
If the figure is not adjusted, its displayed as Figure 1.
14行目(line)
tagに番号を決める。
アクションメソッド内で押された番号を識別できるようにする。
これによって、
図2のように 1クリックで2枚表示される等のエラーを防ぐ。
setting the tag number.
This method shows Identification of number
that pushed in method of action.
And prevented two sheets of card being displayed
by clicking one degree like a Figure 2.
19行目(line)
カードの枚数。
The number of sheets of card.
図1(Figure 1) 図2 (Figure 2)
(void)loadImages {
images = [[NSMutableArray alloc] init];
int i;
for ( i = 0; i < 19; i++ )
{
NSString *str = [NSString stringWithFormat:@"img%d.png", i];
[images addObject:[UIImage imageNamed:str]];
}
画像をファイルから読み込み、NSImageのインスタンスに格納。
4行目、0から18までカウントアップ。
The image is read from the file, and it stores in the instance of NSImage.
The fourth line shows loop that does count up from 0 to 18.
後は追加する画像のピクセルの変更、フォーマットの変更(PNGに)を行う。
Its displayed as follows by change of the pixel
of the added image and Format to PNG.
見た目は変わってきた。
次はスコア、ハイスコアの設定をやろうと思う。
Externals have changed.
Next, i'll try to set a score and a high score data.