我做了一个小程序,就是随着按键图片上下左右移动。
可是运行时却发再只有按第二下时,第一个按键事件才响应???
(其中还要判断数组,如果为1则移动,否则不移动。)
是不是与刷新有关??

解决方案 »

  1.   

    with Image99 do
        case key of
           vk_up:
            begin
                if (QqY - 1 >= 0) and (ArrMove[QqY-1,QqX]<>1)   then
                  begin
                   Image99.top:=32*QqY;
                   Image99.Left :=32*QqX;
                   Image100.top:=32*QqY;
                   Image100.Left :=32*QqX;
                   QqY:=QqY-1;
                  end;
                end;
    vk_Down: begin
         if (QqY+1<=8) and  (ArrMove[QqY+1,QqX]<>1) then
            begin
            Image100.top:=32*QqY;
            Image100.Left :=32*QqX;
            Image99.top:=32*QqY;
            Image99.Left :=32*QqX;
            QqY:=QqY+1;
            end;
            end;
    vk_Left: begin
         if (QqX-1>=0) and  (ArrMove[QqY,QqX-1]<>1) then
           begin
            Image99.top:=32*QqY;
            Image99.Left :=32*QqX;
            Image100.top:=32*QqY;
            Image100.Left :=32*QqX;
            QqX:=QqX-1;
           end;
            end;
    vk_Right: begin
         if (QqX+1<=8) and  (ArrMove[QqY,QqX+1]<>1) then
           begin
            Image99.top:=32*QqY;
            Image99.Left :=32*QqX;
            Image100.top:=32*QqY;
            Image100.Left :=32*QqX;
            QqX:=QqX+1;
            end;
            end;
      

  2.   

    你應該先包焦點集中在你的Image1上!