Firstly, scuse me for my english speaking, i'm french.
For my last bachelor year, i've to create a small video game using irrlicht . But i've a problem .
Steps :
1) i create a node, i set his position, and i push him in a vector wich is stored in a class .
2) i need to delete some nodes in this vector : myVec->remove(); but the compiler said " WHAT THE gently caress ARE U DOING ???? segFault"
I really need your help because i don't know how to delete these nodes . I've thought about a solution that use sceneManager->clear(), but draw all the scene isn't a good solution ...
Some code : ( if the node and the nodeList are at the same place, delete nodeList)
Code: Select all
bool CollisionManager::collisionWithBubble(ISceneNode *node, vector<ISceneNode*> nodeList, Game &game){
if(node){
for(int i=0; i<nodeList.size(); ++i){
if(node->getPosition()==nodeList[i]->getPosition()){
cout<<"X "<<nodeList[i]->getPosition().X/3<<"Y "<<nodeList[i]->getPosition().Y/3<<endl;
if(game.bubbleList[3-nodeList[i]->getPosition().Y/3][nodeList[i]->getPosition().X/3].getLvl()==3)
nodeList[i]->remove();
game.bubbleList[3-nodeList[i]->getPosition().Y/3][nodeList[i]->getPosition().X/3].up();
return true;
}
}
}
return false;
}
Code: Select all
for(int i=0; i<4; i++){
for(int j=0; j<4; j++){
if(tempo[i][j].getId()!=-1){
scene::ISceneNode * node2 = node->clone();
node2->setVisible(true);
if (node2){
node2->setPosition(core::vector3df(tempo[i][j].getX()*3,tempo[i][j].getY()*3,-1));
if(tempo[i][j].getLvl()>0){
node2->setScale(core::vector3df(tempo[i][j].getLvl()*0.5,tempo[i][j].getLvl()*0.5,tempo[i][j].getLvl()*0.5));
}
else
node2->setScale(core::vector3df(0.25,0.25,0.25));
/*node2->addAnimator(anim);
anim->drop();*/
}
nodeList.push_back(node2);
}
}
}
P. Titouan
CERI Avignon