I'm getting an error that I can't seem to figure out. I'm trying to write a small template for GUI buttons, and I'm finding it does not run properly. It seems that the variable totalButtons changes at some point.
Createint clicked=0; int totalButtons=1; unsigned char *buttonID; buttonID= new unsigned char [totalButtons]; signed short *buttonX; buttonX= new signed short [totalButtons]; signed short *buttonY; buttonY= new signed short [totalButtons]; unsigned char *buttonW; buttonW= new unsigned char [totalButtons]; unsigned char *buttonH; buttonH= new unsigned char [totalButtons]; Drawdraw_set_color(c_white); for(int i=0; i<totalButtons; i++){ // if(i+1==clicked){ // draw_set_color(c_gray); //draw_rectangle(buttonX[i],buttonY[i],buttonX[i]+buttonW[i],buttonY[i]+buttonH[i],false); // draw_set_color(c_white); // }else{ //draw_rectangle(buttonX[i],buttonY[i],buttonX[i]+buttonW[i],buttonY[i]+buttonH[i],false); // } }
draw_set_color(c_black); //for(int i=0; i<totalButtons; i++){ //draw_rectangle(buttonX[i],buttonY[i],buttonX[i]+buttonW[i],buttonY[i]+buttonH[i],true); //draw_text(buttonX[i],buttonY[i],buttonText[i]); //} I commented out a lot to try to narrow it down, but it does work if the first for is changed to a variable or number other than totalButtons
EDIT: I fixed it by changing "int totalButtons" to "local int totalButtons" Is this normal? or an oversight?
|