首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGpoint到NSMutableArray中的CCmenuItem

CGpoint到NSMutableArray中的CCmenuItem
EN

Stack Overflow用户
提问于 2012-06-14 04:30:24
回答 1查看 131关注 0票数 0
代码语言:javascript
复制
    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),但没有成功。我想不出它的语法。

EN

回答 1

Stack Overflow用户

发布于 2012-06-14 04:35:35

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

类似于:

代码语言:javascript
复制
[brickorna objectAtIndex:a].position = [[gridPoints objectAtIndex:a] CGPointValue];

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11022842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档