Yeah, it should be linear_reverse_search. As for where 'node' came from, it is the node that you are about to remove from the scene. It could come from anywhere.
As I said before, unless you have a really good reason to maintain an external array of scene nodes, it should be avoided. Why do you think that you need the external array?
Travis
node deletion
-
- Posts: 26
- Joined: Thu Apr 26, 2007 6:57 am
Ah, sorry I lost track of which post was which. Yes, it makes sense to use an array for bullets and for enemies. If you had an array of bullets that would go away after some preset time interval, you wouldn't need to search for which bullet to remove. You would probably have a function to walk over the bullets and see if any of them passed through a bad guy since the last time you checked. If your bullets could 'expire', you'd check to see if each had expired, and if it had you'd remove it from the scene and from the array.
Travis
Travis
-
- Posts: 26
- Joined: Thu Apr 26, 2007 6:57 am
yea, I have a thing for the bullets alread. its not an array though. I still have a question about making the array because I dont know how to do it. I tried a way and no errors but the program crashed so i guess i did it wrong. I still dont understand how the "node" came from. this is what i did.
and this is the part where i use node->remove();
srry for being so stupid.
Code: Select all
core::array<scene::ISceneNode*> SceneNodes; //da array for enemy(boxes)
//create a node and add it to the array
SceneNodes.push_back(smgr->addCubeSceneNode(100.0f));
scene::ISceneNode* bnode = SceneNodes[0];
Code: Select all
s32 found = SceneNodes.linear_reverse_search(bnode);
if (found != -1)
SceneNodes.erase(found);
bnode->remove();
-
- Posts: 26
- Joined: Thu Apr 26, 2007 6:57 am