本文介绍了什么是coccos2d中的CCARRAY_FOREACH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在coccos2d中看到一个宏CCARRAY_FOREACH,其实是什么呢?

I see a macro CCARRAY_FOREACH in coccos2d, actually what does it? can we do alternativesolution instead of it?i am using following code for spriteBatchNode?

     CCARRAY_FOREACH([spriteBatch children], sprite)
{

    ...................
}


推荐答案

它是一个宏,用于循环遍历CCArray中的每个对象...另一种方法是客观-c的foreach for(object in array),如下所示:

it is a macro for looping through each object inside a CCArray... an alternative would be objective-c's foreach for (object in array) that goes like this:

for (CCSprite *sprite in [spriteBatch children]) {
    ...
}


$ b b

这是NSArray和NSMutableArray,但我认为它应该工作正常CCArray以及。

this is for NSArray and NSMutableArray but i think it should work fine for CCArray as well.

这篇关于什么是coccos2d中的CCARRAY_FOREACH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:21