📄 sprite.h
字号:
/*
* ==============================================================================
* Name : Sprite.h
* Part of : RGA Game Example
* Interface :
* Description : basic drawable sprite
* Version : 1.0
*
* Copyright (c) 2007-2008 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ==============================================================================
*/
#ifndef __SPRITE_H__
#define __SPRITE_H__
#include "SpriteBase.h"
struct TSpriteFrame
{
IBitmap* iBitmap;
IBitmap* iMask;
};
class CSprite : public CSpriteBase
{
public:
CSprite(CApplicationBase& aApp);
virtual ~CSprite();
/**
* AddFrame
* add new animation frame into the sprite
* @param aFrame new animation frame
* @return index of the new frame
*/
TInt AddFrame(const TSpriteFrame& aFrame);
/**
* Frame
* access to sprite animation frames
* @param aIndex index from AddFrame
* @return animation frame
*/
TSpriteFrame& Frame(TInt aIndex);
/**
* SetAnimationSequence
* @param aFrameIndices an array of animation indices returned by AddFrame
* @param aFrameCount number of frames in frame array
*/
void SetAnimationSequence(const TUint32* aFrameIndices, const TUint32 aFrameCount);
/**
* SetAnimationSpeed
* @param aFPS animation frames per second
*/
void SetAnimationSpeed(const TReal64 aFPS);
/**
* Update
* update the sprite position by adding its
* direction into the position. The animation
* is updated.
* @param aFrametime frame time multiplier
*/
virtual void Update(const TReal64 aFrametime);
/**
* Draw
* draw sprite to its current location
* @param aContext context to draw sprite into
* @param aCamera camera coordinate to subtract from sprite coordinates
*/
virtual void Draw(IGraphicsContext& aContext, const TVector2& aCamera);
private:
RArray<TSpriteFrame> iFrames;
TUint32* iAnimationIndices;
TUint32 iAnimationIndicesCount;
TReal64 iAnimationSpeed;
TReal64 iAnimationIndex;
};
#endif /* __SPRITE_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -