void GameMainLayer::update(float time) { if (hero->state == 0) this->isHeroDrop(); CCPoint pos1 = (map->getChildByTag(0))->getPosition(); CCPoint pos2 = (map->getChildByTag(1))->getPosition(); //检测主角是否吃到星星 for (int i = 0; i < 5; i++) { if (pos1.x <= 100 && (pos1.x + 480) >= 100) { GameObjStar *star = (GameObjStar *)(map->stars1)->objectAtIndex(i); if (star->get_visible() && isCollision(ccp(100,hero->getPosition().y + 62.5), ccp(pos1.x + 86 + 96*i, 280), 40, 35, 18.25, 17.75)) { star->set_visible(false); gameMark->addNumber(100); } } else { GameObjStar *star = (GameObjStar *)(map->stars2)->objectAtIndex(i); if (star->get_visible() && isCollision(ccp(100,hero->getPosition().y + 62.5), ccp(pos2.x + 86 + 96*i, 280), 40, 35, 18.25, 17.75)) { star->set_visible(false); gameMark->addNumber(100); } } } }