本文介绍了无法根据条件访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我分配 int r,s,t,u,v; 没有if条件正常工作。

当我指定 int r = 0,s = 0,t = 0,u = 0,v = 0; 所有条件都有效。

我是无法找到错误。

 int r,s,t,u,v; 
if((mouseXPos< 130&& mouseXPos> 30&& mouseYPos> 365&& mouseYPos< 410)&&(s == 0)&& (t == 0)&&(u == 0)&&(v == 0))
{
drawMenu(0);
r = 1;
}
if((mouseXPos< 230&& mouseXPos> 130&& mouseYPos> 365&& mouseYPos< 410)&&(r == 0 )&&(t == 0)&&(u == 0)&&(v == 0))
{
drawMenu(1);
s = 1;
}
if((mouseXPos< 330&& mouseXPos> 230&& mouseYPos> 365&& mouseYPos< 410)&&(r == 0 )&&(s == 0)&&(u == 0)&&(v == 0))
{
drawMenu(2);
t = 1;
}
if((mouseXPos< 430&& mouseXPos> 330&& mouseYPos> 365&& mouseYPos< 410)&&(r == 0 )&&(s == 0)&&(t == 0)&&(v == 0))
{
drawMenu(3);
u = 1;
}
if((mouseXPos< 530&& mouseXPos> 430&& mouseYPos> 365&& mouseYPos< 410)&&(r == 0 )&&(t == 0)&&(u == 0)&&(s == 0))
{
drawMenu(4);
v = 1;
}
if(mouseXPos< 130&& mouseXPos> 30&& mouseYPos< 185&& mouseYPos> 140)
{
drawMenu (5);
}

void drawMenu(短b)
{

int k = 0,i = 0,j = 0;
if(b == 0)
{
a =& touch_menu [0];
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
setColor(CYAN);
for(i = 0; i< a-> c; i ++)
{
drawText(38,150 + j,a-> sub_Menu [i],0);
j = j + 45;
}


}

否则if(b == 1)
{
a =& touch_menu [1] ;
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
setColor(CYAN);
for(i = 0; i< a-> c; i ++)
{
drawText(138,195 + j,a-> sub_Menu [i],0);
j = j + 45;
}

}
else if(b == 2)
{
a =& touch_menu [2];
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
setColor(CYAN);
for(i = 0; i< a-> c; i ++)
{
drawText(238,240 + j,a-> sub_Menu [i],0);
j = j + 45;
}

}
else if(b == 3)
{
a =& touch_menu [3];
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
setColor(CYAN);
for(i = 0; i< a-> c; i ++)
{
drawText(338,195 + j,a-> sub_Menu [i],0);
j = j + 45;
}
}
else if(b == 4)
{

a =& touch_menu [4];
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
setColor(CYAN);
for(i = 0; i< a-> c; i ++)
{
drawText(438,285 + j,a-> sub_Menu [i],0);
j = j + 45;
}
}
else if(b == 5)
{
a =& touch_menu [5];
for(k = 0; k< a-> c; k ++)
{
setColor(GRAY);
drawRectangle(a-> startXPos,a-> startYPos - (k + 1)* a-> height,a-> width,a-> height);
}
for(i = 0; i< a-> c; i ++)
{
drawText(138,150 + j,a-> sub_Menu [i],0 );
j = j + 45;

}
}
}
解决方案


这篇关于无法根据条件访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 06:36