DXDraw.Initialize; end; end; procedure TMainForm.DXDrawMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin AnchorX := x + Trunc(PlayerSprite.x)-320; AnchorY := y + Trunc(PlayerSprite.y)-240; {将鼠标在屏幕上点击的位置转换到游戏世界中} PlayerSprite.CanMove:=True; {此参数允许鼠标拖动} end; procedure TMainForm.DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if PlayerSprite.CanMove then begin AnchorX := x + Trunc(PlayerSprite.x)-320; AnchorY := y + Trunc(PlayerSprite.y)-240; {在鼠标拖动过程中将鼠标在屏幕上点击的位置转换到游戏世界中} end; MouseX:=X; MouseY:=Y; {鼠标当前位置} end; procedure TMainForm.DXDrawMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin PlayerSprite.CanMove:=False; end; procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); begin DXSpriteEngine.Free; end; procedure TPlayerSprite.MoveTo(MoveCount: Integer; Direction: TDirection); begin {控制精灵往各个方向移动} case Direction of DrUp: begin Y := Y-(150/1000)*MoveCount; Inc(steps); AnimPos:=steps div speed+20+1; {当前动画中播放的图片序号}
|
正在阅读:用Delphi + DirectX开发简单RPG游戏用Delphi + DirectX开发简单RPG游戏
2004-02-14 09:34
出处:电脑爱好者
责任编辑:linjixiong
键盘也能翻页,试试“← →”键