We just need to use the correct index to retrieve the objects from their respective vector:
To retrieve meteor sprites, we'll use the
resetMeteor
method:void GameLayer::resetMeteor(void) { //if too many objects on screen, return if (_fallingObjects.size() > 30) return; auto meteor = _meteorPool.at(_meteorPoolIndex); _meteorPoolIndex++; if (_meteorPoolIndex == _meteorPool.size()) _meteorPoolIndex = 0; int meteor_x = rand() % (int) (_screenSize.width * 0.8f) + _screenSize.width * 0.1f; int meteor_target_x = rand() % (int) (_screenSize.width * 0.8f) + _screenSize.width * 0.1f; meteor->stopAllActions(); meteor->setPosition(Vec2(meteor_x, _screenSize.height + meteor->getBoundingBox().size.height * 0.5)); //create action auto rotate = RotateBy::create(0.5f , -90); auto repeatRotate = RepeatForever::create( rotate ); auto sequence = Sequence::create ( ...