You can indeed, CCArray can to hold any instances derived from CCObject.
Can you show us more code, especially the definition of boxArray?
Using boxArray[i+j] you treat it as if was an array of CCArrays, notation array[index] is equivalent to *(array + index). As the STL said:
When a C or C++ compiler sees this, the array is immediately rewritten to be a pointer. This rewriting is so immediate that sizeof and decltype will observe a pointer.
What you probably meant was: boxArray->objectAtIndex( i+j ) = box;
You can indeed, CCArray can to hold any instances derived from CCObject.
Can you show us more code, especially the definition of boxArray?
Using boxArray[i+j] you treat it as if was an array of CCArrays, notation array[index] is equivalent to *(array + index). As the STL said:
When a C or C++ compiler sees this, the array is immediately rewritten to be a pointer. This rewriting is so immediate that sizeof and decltype will observe a pointer.
What you probably meant was: boxArray->objectAtIndex( i+j ) = box;
bool GameScene::ccTouchBegan(CCTouch *pTouch, CCEvent* pEvent)
{
CCPoint touchPoint = pTouch->getLocation();
CCLog("Touches Began..(%f,%f)",touchPoint.x,touchPoint.y);
for (int i = 0; i <BOX_WIDTH; i++){
for (int j = 0; j < BOX_HEIGHT; j++) {
CCScale9Sprite *box;
box = (CCScale9Sprite*)boxArray[i+j];
CCRect rect =box->boundingBox();
if (rect.containsPoint(touchPoint)) {
CCLog("Touch...");
return true;
} else {
}
}
}
return true;
}
I know this code is wrong. but I don’t know what to do.
I tried to 'CCScale9Sprite::create(“Red_default.png”, CCRectMake(0, 0, 56, 56));'inserted box…and that boxes is boxArray[].
Then. boxArray[] input TOUCH!!
I want to touch box that I declared the CCScale9Sprite box.