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

📄 sprite.h

📁 S60培训教材代码(连载)
💻 H
字号:
/* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

#ifndef __SPRITE_H__
#define __SPRITE_H__

#include <e32base.h>

class CFbsBitmap;

/*! 
  @class CSprite
  
  @discussion An instance of class CSprite represents an object being displayed on the screen
  */
class CSprite : public CBase
    {
    public:

    /*!
      @function NewL
  
      @discussion Construct a CSprite using two phase construction, and return a pointer to the created object
      @param aXVelocity The velocity of the sprite on the x axis
      @param aYVelocity The velocity of the sprite on the y axis
      @param aInitialPosition The starting position of the sprite on the screen
      @result a pointer to the created instance of CSprite
      */
        static CSprite* NewL(TInt aXVelocity, TInt aYVelocity, const TPoint& aInitialPosition);

    /*!
      @function NewLC
  
      @discussion Construct a CSprite using two phase construction, and return a pointer to the created object
      @param aXVelocity The velocity of the sprite on the x axis
      @param aYVelocity The velocity of the sprite on the y axis
      @param aInitialPosition The starting position of the sprite on the screen
      @result a pointer to the created instance of CSprite
      */
        static CSprite* NewLC(TInt aXVelocity, TInt aYVelocity, const TPoint& aInitialPosition);

    /*!
      @function Position
  
      @discussion Return the position of the sprite on the screen
      @result The position
      */
        TPoint Position() const;

    /*!
      @function SetPosition
  
      @discussion Sets the position of the sprite on the screen - note this is not validated!!
      @param aNewPosition The new position
      */
        void SetPosition(const TPoint& aNewPosition);

    /*!
      @function Move
  
      @discussion Move the sprite
      @param aSize The size of the sprite
      @param aBounds The rectangle the sprite is allowed to move in
      */
        void Move(const TSize& aSize, const TRect& aBounds);

    /*!
      @function ~CSprite
  
      @discussion Destroy the object and release all memory objects
      */
        ~CSprite();

    private:

    /*!
      @function CSprite
  
      @discussion Perform the first phase of two phase construction 
      @param aXVelocity The velocity of the sprite on the x axis
      @param aYVelocity The velocity of the sprite on the y axis
      @param aInitialPosition The starting position of the sprite on the screen
      */
        CSprite(TInt aXVelocity,TInt aYVelocity, const TPoint& aInitialPosition);

    /*!
      @function ConstructL
  
      @discussion  Perform the second phase construction of a CSprite object
      */
        void ConstructL();

    public:
        // functions to enable access to private member variables
        void SetXVelocity(TInt aNewXVel);
        void SetYVelocity(TInt aNewYVel);
        TInt GetXVelocity() const;
        TInt GetYVelocity() const;  

        void SetBounceCount(TInt aNewCount);
        TInt GetBounceCount() const;

    private: // data

        /** position of sprite */
        TPoint iPosition;

        /** x axis velocity */
        TInt iXVelocity;

        /** y axis velocity */
        TInt iYVelocity;    

        /** number of times ball has bounced */
        TInt iBounceCount;

    };

#endif // __SPRITE_H__

⌨️ 快捷键说明

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