我想实现如下的效果:类似 飞机游戏,按住 发射子弹 键,子弹就连续发射,同时按上下左右键还能让飞机上下左右移动。我试了下在edit里安住一个键(键A)时按下另一个键(键B),则 键A 的效果就没了,不知 飞机 游戏是如何做到的?或者 按住 发射子弹键,同时斜线飞行,再按下原子弹键,则有4个键同时作用,应该如何处理??

解决方案 »

  1.   

    一个例子, 当同时按光标向上移动键、光标向左移动键和A时,窗体标题更新为当前时间。procedure TForm1.FormCreate(Sender: TObject);
    begin
      Self.KeyPreview := True;
    end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);
    var
      KS: TKeyboardState;
    begin
      GetKeyboardState(KS);
      if ((KS[vk_up] = 128) or (KS[vk_up] = 129)) and
         ((KS[vk_left] = 128) or (KS[vk_left] = 129)) and
         ((KS[ord('A')] = 128) or (KS[ord('A')] = 129)) then
        Self.Caption := FormatDateTime('yyyy-MM-dd hh:nn:ss', now);
    end;
      

  2.   

    http://topic.csdn.net/u/20100222/15/1598666C-2787-4D1D-BF4E-1EAE4E273405.html