GetCurrent??
Posted: Fri Nov 26, 2010 12:21 am
How might I go about a "GetCurrent" function. Basically I want the node you click on, to be selected. Then from there I can delete the current one from the vector or move it.
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
Code: Select all
int GetCurrent() {
return Current;
}
void EraseCurrent() {
Nodes.erase(Nodes.begin() + GetCurrent()); // Nodes being the vector
}
Alright, sorry for the bad wording and short description everyone, I was tired when I posted that problem. Thank you all though, I think I can work N64vNES's thingy into exactly what I need to thanks man.N64vSNES wrote:I'm not positive I understood your question, I'm going to assume you are using C++.
________
|Node 1| -------------> if ( Clicked == true ) { Current == 1; }
|__ ___|
________
|Node 2|-------------> if ( Clicked == true ) { Current == 2; }
|__ ___|
________
|Node 3|-------------> if ( Clicked == true ) { Current == 3; }
|__ ___|
etc...Code: Select all
int GetCurrent() { return Current; } void EraseCurrent() { Nodes.erase(Nodes.begin() + GetCurrent()); // Nodes being the vector }
I think thats what you mean?
Basically I'm making a map editor in c++ and I'm having major problems with deleting the selected object and even MAKING an object be selected. You click on a node to select it, and after a node is selected you can delete it, or right click it to open it's properties. Now that I have a better description, do you know how I can make it so that clicking on a node/object will "set it to selected" so that I can do those things?N64vSNES wrote:I still don't get it but I think thats anwsered his question =]
Code: Select all
Tile* selected = 0;
//pseudocode ?
if(event.type == MouseLButtonPressed) {
//the "algorithm" to get a tile at a mouse pos should be pretty easy
selected = GetTileAt(event.mouse.x, event.mouse.y);
}
if(event.type == KeyDeletePressed) {
if(selected) selected->ResetToDefaultTile();
}
if(event.type == MouseRButtonPressed) {
if(selected) OpenPropertiesDialog(selected);
}
This and NES's will be great if I work them together. The game isn't tile based in that way though, it uses backdrops like this for example.adikid89 wrote:Sorry if the code wasn't helpfulCode: Select all
Tile* selected = 0; //pseudocode ? if(event.type == MouseLButtonPressed) { //the "algorithm" to get a tile at a mouse pos should be pretty easy selected = GetTileAt(event.mouse.x, event.mouse.y); } if(event.type == KeyDeletePressed) { if(selected) selected->ResetToDefaultTile(); } if(event.type == MouseRButtonPressed) { if(selected) OpenPropertiesDialog(selected); }