如果'Filloval'
出现 4,则必须选择所有 4 个椭圆。如果同一个椭圆被选中 4 次,则只选中 1 个椭圆,因此代码不应终止。但是,我当前的代码在选择相同的椭圆形四次时终止。
我们创建了一个矩阵,如果我们点击一个椭圆,我们将删除对应于一个椭圆的列,这样如果我们重复按下一个椭圆,它就不会结束。
问题是,如果单击 (14) 矩阵中的一个椭圆来创建 (13) 矩阵,则必须保持 (13) 矩阵,但事实并非如此。
for mouse = 1 : 4 % mouse 4 click
ShowCursor (0);
SetMouse(xCenter, yCenter*1.9, windowPtr);
click = 1;
while click == 1;
[xMouse, yMouse, buttons] = GetMouse(windowPtr);
inside1 = IsInRect(xMouse, yMouse, Tchoicecenter);
inside2 = IsInRect(xMouse, yMouse, Tchoicecenter2);
inside3 = IsInRect(xMouse, yMouse, Tchoicecenter3);
inside4 = IsInRect(xMouse, yMouse, Tchoicecenter4);
if inside1 == 1
Rectlocation(:,mouse) = Tchoicecenter;
if any(buttons)
break
end
elseif inside2 == 1
Rectlocation(:,mouse) = Tchoicecenter2;
if any(buttons)
break
end
elseif inside3 == 1
Rectlocation(:,mouse) = Tchoicecenter3;
if any(buttons)
break
end
elseif inside4 == 1
Rectlocation(:,mouse) = Tchoicecenter4;
if any(buttons)
break
end
end
Tovalcenter = CenterRectOnPoint(ovalBaseRect, TXpos, TYpos);
Tovalcenter2 = CenterRectOnPoint(ovalBaseRect, TXpos2, TYpos2);
Tovalcenter3 = CenterRectOnPoint(ovalBaseRect, TXpos3, TYpos3);
Tovalcenter4 = CenterRectOnPoint(ovalBaseRect, TXpos4, TYpos4);
Screen('FillOval', windowPtr, TColor, Tovalcenter);
Screen('FillOval', windowPtr, TColor, Tovalcenter2);
Screen('FillOval', windowPtr, TColor, Tovalcenter3);
Screen('FillOval', windowPtr, TColor, Tovalcenter4);
end
mouseans = [1:4 ; inside1 inside2 inside3 inside4];
a = find(mouseans(2,:) == 1); % mouse click (True == 1)
mouseans(:,a) = []
end
我目前的结果:
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 2 3 % 4 oval click
0 0 0
mouseans = 1 2 4 % 3 oval click
0 0 0
mouseans = 2 3 4 % 1 oval click
0 0 0
期望的结果:
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 3 % 4 oval click
0 0
mouseans = 1 % 3 oval click
0
mouseans = [] % 1 oval click
如何在程序不终止的情况下单击所有四个椭圆?