0
    brickorna = [NSMutableArray arrayWithCapacity:10];

    int chipSize = 100;
    gridPoints = [NSMutableArray arrayWithObjects:
                  [NSValue valueWithCGPoint:CGPointMake(chipSize, chipSize)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*2, chipSize)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*3, chipSize)],

                  [NSValue valueWithCGPoint:CGPointMake(chipSize, chipSize*2)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*2, chipSize*2)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*3, chipSize*2)],

                  [NSValue valueWithCGPoint:CGPointMake(chipSize, chipSize*3)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*2, chipSize*3)],
                  [NSValue valueWithCGPoint:CGPointMake(chipSize*3, chipSize*3)],
                  nil];


    for (int i = 0; i <= 8; i++) { //createing chips and adding them to array
    CCMenuItemImage *bricka = [CCMenuItemImage itemFromNormalImage:@"Icon.png" selectedImage:nil];
        [brickorna addObject:bricka];
    }

    for (int a = 0; a <= 8; a++) { //adding the chips to scene

        CCMenuItemImage *tempB = [brickorna objectAtIndex:a];
        tempB.position = [[gridPoints objectAtIndex:a] CGPointValue];

        [self addChild:[brickorna objectAtIndex:a]];
    }

I'm trying to make a tile game but got stuck. see the line "this is wrong". I'm trying to pass the CGPoint coordinates from the gridPointArray to the CCmenuItem(bricka) in the BrickornaArray, but without luck. I can't figure out the syntax for it.

4

1 に答える 1

0

CCMenuItemImage には 'CGPointValue' という名前のプロパティがありません - という名前の CGPointValue タイプのプロパティがあり、これpositionを設定する必要があります。

何かのようなもの:

[brickorna objectAtIndex:a].position = [[gridPoints objectAtIndex:a] CGPointValue];

プロパティは、positionCCMenuItem (および CCMenuItemImage) が継承する CCNode で宣言されます。

于 2012-06-13T20:35:35.470 に答える