Hi,
I have two classes - Graph and Node. In Graph class I declare an array of Nodes. In the Update method of class Graph I have a loop for checking each node... So, I have 25 nodes. At the beginning, each node has a texture "NOTVISITED". If I click on a node it should change its texture to "CLICKED". When I click on another node, my first node changes its texture to "VISITED" and the now-clicked one changes texture to "CLICKED". That works ok, but there's one problem. Namely, if there's a node with a texture "CLICKED" and I click on another node, first node changes texture to "VISITED", but just after I do some mouse movement or I click again... And it should change its texture to "VISITED" right after clicking on another node. I'm just learning coding 2d apps and I have no idea how to fix it. Could someone help me?
Here's the code of Graph::Update:
for (int i=0; i<size; i++) {
if (gm.MouseClicked(w[i].getSpr(), win, ev)) { //win - window, ev - event
for (int j=0; j<size; j++) {
if (w[j].clicked) { w[j].clicked=false; break; }
}
if (!w[i].visited) w[i].visited=true;
w[i].clicked=true;
}
if (w[i].clicked)
w[i].tex=CLICKED;
else {
if (w[i].visited)
w[i].tex=VISITED;
else
w[i].tex=NOTVISITED;
}
w[i].Update(win, gm, ev); //gm - gameobject
}
w[] is my array of Nodes