我原来要处理的逻辑是这样的:
触屏捕获位置,然后再从已有的数组中遍历每一个BOX查看是否选中某一BOX,如果某一BOX被选中,则返回BOX的某一变量(Item*)。
代码如下:
Item* Spot::SearchSpot(Point pointClicked){
Object* obj = NULL;
Box* box_here = NULL;
CCARRAY_FOREACH(boxPointer,obj){
box_here = dynamic_cast(obj);
if ( box_here->isClickMe(pointClicked)){
return box_here->getItem();
}
}
return NULL;
}
然后我追踪某一Box中的Item:
void Box::setItem(Item* item_get){
m_item = item_get;
}
发现赋值以后很正常:

当经过数组遍历找到该BOX后,调用return box_here->getItem()
Item* Box::getItem(){
return m_item;
}
出现了异常:
求解答。。小白刚入门,刚熟悉V2版本,结果又出3.0了。。各种蛋疼。。
