📄 ddbouncingball_engine.h
字号:
// DDBouncingBall_Engine.h
// ---------------------------
//
// Copyright (c) 2002 Symbian Ltd. All rights reserved.
//
////////////////////////////////////////////////////////////////////
//
// class CDDBouncingBallEngine
//
// Derives from CTimer both to control behaviour of our bouncing
// ball, and because we our CDirectScreenAccess container class must
// be an Active Object.
//
// We implement MDirectScreenAccess rather than MAbortDirectScreenAccess
// so that we are notified not only when to abort drawing, but also when
// its safe to restart.
//
// Bouncing ball is achieved by blitting a bitmap of a ball to the drawing
// region. Collisions are checked and direction variable updated accordingly.
// One of the benefits of the Direct Screen Access framework is that
// we can be confident that the TRegion that we are allowed to draw to
// will not overlap or interfere with something being drawn by the Windows
// server. The drawable region is updated before a Restart notification
// is received.
//
////////////////////////////////////////////////////////////////////
#ifndef __DDBOUNCINGBALL_ENGINE_H
#define __DDBOUNCINGBALL_ENGINE_H
#include <w32std.h>
enum TDDBouncingBallEnginePanics
{
EDDBouncingAlreadyStarted = 1,
EDDBouncingAlreadyStopped
};
class CDDBouncingBallEngine : public CTimer, public MDirectScreenAccess
{
public:
// Construction & destruction
CDDBouncingBallEngine
(
RWsSession& aClient,
CWsScreenDevice& aScreenDevice,
RWindow& aWindow,
CFbsBitmap* aBitmap,
CFbsBitmap* aBitmapMask,
TInt aXVelocity,
TInt aYVelocity
);
~CDDBouncingBallEngine();
void ConstructL();
public:
// Start and stop the bouncing ball
void StartBouncingL();
void StopBouncing();
// Are we bouncing
inline TBool Bouncing(){return iBouncing;}
private:
// Implement MDirectScreenAccess
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
private:
// Implement CTimer
void RunL();
void DoCancel();
private:
void MoveBall();
private:
// Window server handling
RWsSession& iClient;
CWsScreenDevice& iScreenDevice;
RWindow& iWindow;
// Direct Screen Access
CDirectScreenAccess* iDirectScreenAccess;
CFbsBitGc* iGc;
RRegion* iRegion;
// Bouncing ball bitmap images
CFbsBitmap* iBallImage;
CFbsBitmap* iBallImageMask;
// Positional plus directional information
TPoint iPosition;
TInt iXVelocity;
TInt iYVelocity;
// Are we bouncing
TBool iBouncing;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -