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]];
    }

我正在尝试制作瓷砖游戏,但被卡住了。请参阅“这是错误的”行。我试图将 CGPoint 坐标从 gridPointArray 传递到 BrickornaArray 中的 CCmenuItem(bricka),但没有运气。我无法弄清楚它的语法。

4

1 回答 1

0

CCMenuItemImage 没有名为“CGPointValue”的属性 - 它有一个CGPointValue类型的属性,名为position,这是您应该设置的。

就像是:

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

position属性在 CCNode 中声明,CCMenuItem(和 CCMenuItemImage)从中继承。

于 2012-06-13T20:35:35.470 回答