DXSprite.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:2k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1998-1999 DXGuide.  All Rights Reserved.
  2. // File: DXSprite.h
  3. #ifndef _DXSPRITE__H
  4. #define _DXSPRITE__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. class CDXMap;
  9. class CDDDevice;
  10. class CDDSurface;
  11. class CPackFileManager;
  12. class CDXSprite : public  CObject
  13. {
  14. DECLARE_SERIAL(CDXSprite);
  15. public:
  16. CDXSprite(void);
  17. virtual ~CDXSprite();
  18. public:
  19. bool Create(CDDSurface*  pSurface,
  20. int  nCellWidth, int  nCellHeight,
  21. bool  bAutoDelete = false);
  22. bool Create(CDDDevice*  pDDDevice,
  23. LPCTSTR  lpszFileName,
  24. int  nCellWidth, int  nCellHeight,
  25. CPackFileManager*  pPackFileManager = NULL,
  26. bool  bTrans = true);
  27. bool Create2(CDDDevice*  pDDDevice,
  28. LPCTSTR  lpszFileName,
  29. int  nHoriBlocks, int  nVertBlocks,
  30. CPackFileManager*  pPackFileManager = NULL,
  31. bool  bTrans = true);
  32. public:
  33. void MoveTo(int  nX, int  nY);
  34. void Move(int  nDeltaX, int  nDeltaY);
  35. void SetFrame(int  nFrame);
  36. void NextFrame(void);
  37. void PrevFrame(void);
  38. void SetZ(int  nZ);
  39. int GetZ(void) const;
  40. int GetCenterX(void) const;
  41. int GetCenterY(void) const;
  42. int GetCellWidth(void) const;
  43. int GetCellHeight(void) const;
  44. int GetCurFrame(void) const;
  45. int GetTotalFrames(void) const;
  46. bool IsTrans(void) const;
  47. bool SpriteHit(CDXSprite*  pSprite);
  48. bool TileHit(CDXMap*  pMap, int  iTile);
  49. bool HitTest(int  nX, int  nY);
  50. virtual HRESULT Draw(CDDSurface*  pDestSurface,
  51. LPCRECT  lprcClip = NULL);
  52. virtual HRESULT Draw(LPRECT  lprcDest,
  53. CDDSurface*  pDestSurface);
  54. virtual HRESULT DrawScaled(CDDSurface*  pDestSurface,
  55. float  fFactor);
  56. protected:
  57. void SelectFrame(LPRECT  lprcSrc);
  58. protected:
  59. int  m_nCellWidth;
  60. int  m_nCellHeight;
  61. int m_nCurFrame;
  62. int m_nTotalFrames;
  63. public:
  64. int m_nPosX;
  65. int m_nPosY;
  66. int m_nPosZ;
  67. protected:
  68. CDDSurface* m_pSurface;
  69. bool m_bAutoDelete;
  70. };
  71. #include "DXSprite.inl"
  72. #endif // _DXSPRITE__H