⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cursorlistener.m

📁 国际象棋程序,解压到当前目录,在matlab窗口输入chess即可应用
💻 M
字号:
function cursorListener(hObject, eventdata, handles)
% cursorListener   Activate the cursor.
% Each figure calls this function, via the Buttond down Callback.
%
% Inputs:
% * hObject ... currently not used
% * eventdata ... currently not used
% * handles ... currently not used
% * global board ... chess board and related information
% * global game ... status of the game
%
% Outputs:
% * WindowButtonUpFcn ... sets the Callback for the mouse button up function
% * WindowButtonMotionFcn ... sets the Callback for the mouse motion function
%
% Example
% Set the callback function of the current object to the cursorListener
% |set(gco,'ButtonDownFcn','cursorListener');|
%
% See also: setCursor, stopCursor, reset_cursor
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00 
% 
% Copyright 2006 W.Garn
%
global board
global game

if  game.status
    position = get(gca,'currentPoint');
    xy = [position(1) position(3)];
    xy = xy+.5;
    xy = round(xy);

    cp = xy2matrix(xy);

    %if board.figures(cp(1),cp(2)) ~= ' ' %it is a figure (shouldn't be necessary)
    if board.active_color == getColor(cp) % not that an opponents figure is chosen.
        setCursor(cp);
        set(gcf,'WindowButtonUpFcn',@stopCursor);
        set(gcf,'WindowButtonMotionFcn',@displayCursor);
    end
end
  


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -