3

我正在用一些书学习 cocos2d,即 Pablo Ruiz 的书,这里有一些代码:

[next runAction:[CCSequence actions:[CCDelayTime
                 actionWithDuration:2], 
       [CCFadeIn actionWithDuration:1],
    [CCDelayTime actionWithDuration:2],
     [CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) 
                                                    data:images],nil]];


- (void) cFadeAndShow: (id)sender data:(void*) data
    {
        NSMutableArray *images = data;
        [self fadeAndShow:images];

    }

它给了我一个错误显示在数据上:runAction 中的图像:

Implicit conversion of Objective-C pointer type 'NSMutableArray *' to C pointer type 'void *' requires a bridged cast

我尝试修复它无济于事。我该怎么办?我尝试将 void* 更改为 NSMutableArray,但仍然没有帮助。如何桥接施法?我试过使用__bridge,但它说你不能桥接转换 NSMutableArray。

4

1 回答 1

3

尝试替换此调用:

[CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) data:images],nil]];

有了这个:

[CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) data:(__bridge void*)images],nil]];

然后在您的淡入淡出和显示方法中,将其转换回一个 id:

NSMutableArray *images = (__bridge id) data;
于 2012-07-25T02:03:01.743 回答