onTouchEnd 事件中，代码不能再for循环之后使用？求解

sylalak123
Sat, 20 Jun 2015 16:28:16 +0000

cocos2d-x3.x

void HelloWorld::onTouchEndedBg(Touch* touch, Event* event){

//添加批处理精灵
auto batBlock = SpriteBatchNode::create("block.png", 81);
batBlock->setPosition(Vec2::ZERO);
addChild(batBlock);


auto arrayBlock = HelloWorld::getarrayBlock();

for (int i = 0; i < arrayBlock->count(); i++){

    auto target = (Sprite*)arrayBlock->getObjectAtIndex(i);

    auto point = (Vec2)touch->getLocation();

    if ((target->getBoundingBox().containsPoint(point)))  {

        auto spriteyello = Sprite::createWithTexture(batBlock->getTexture(), CCRectMake(0, 0, BLOCK_W, BLOCK_H));
        spriteyello->setPosition(target->getPosition());
        batBlock->addChild(spriteyello);
    }
}

    ////////////////////////////////////////////////////自定义函数放在这里没有执行，这里的代码都不能执行
    ////////////////////////////////////////////////////CCLOG("evenintrow = %d,evenintcol = %d", introw, intcol);  也没有输出

}

阅读整个主题