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

📄 rpsgameengine.h

📁 roids60 game symbian os application development
💻 H
字号:
// Copyright (c) Symbian Ltd 2008. All rights reserved.

#ifndef __RPSGAMEENGINE_H__
#define __RPSGAMEENGINE_H__

// INCLUDES
#include "rpsappview.h"
#include "rpsGameScreens.h"
#include "commoninterfaces.h"

class CInactivityTimer;

// CLASS DECLARATION
class MEngineObserver
	{
public:
	virtual void UpdateScreen()=0;
	};
		
//-----------------------------------------------------------
class CRpsGameEngine : public CBase, public MAppViewObserver
									 
	{
public: // Construction methods

	/**
	* NewL.
	* Two-phased constructor.
	* Create a CRpsGameEngine object.
	* @aparam aObs a reference to the engine observer
	*/
	static CRpsGameEngine* NewL(MEngineObserver& aObs);

	/**
	* ~CRpsGameEngine 
	* Virtual Destructor.
	*/
	virtual ~CRpsGameEngine();

public:	//From MAppViewObserver
	/**
	 * Called by framework when application focus changes
	 * @aparam aFocus Indicates whether the focus has or has not changed
	 */
	void FocusChanged(TBool aFocus);
	
	/**
	 * Handles key events generated by the player
	 * @aparam aKeyState the key that was pressed
	 */
	void KeyEvent(TUint& aKeyState);
	
	/**
	 * Update the application view with the current game screen
	 */
	void DrawGameScreen();
	
public:	
	/**
	* Static callback method used by the periodic timer
	* Calls GameLoop()
	* @aparam aCallback pointer to the callback function
	*/
	static TInt Tick(TAny* aCallback);
	
	/**
	* Starts the heartbeat timer to drive the game loop
	*/	
	void StartHeartbeat();
	
	/**
	Stops the heartbeat time and pauses the game loop
	aTimedOut boolean indicates whether the inactivity timeout has expired
	ETrue if it has (because the user hasn't interacted with the game)
	EFalse if the heartbeat is stopping because the game has lost focus or is exiting
	*/	
	void StopHeartbeat(TBool aTimedOut = EFalse);
	
	/**
	 * Pause the game in the event of a timeout
	 */
	void PauseGame();
	
	/**
	 * Called when input is received to bring it out of pause
	 */
	void UnpauseGame();
			
private: // Construction and methods that leave

	/**
	* ConstructL
	* 2nd phase constructor.
	*/
	void ConstructL();

	/**
	* CRpsGameEngine 
	* C++ default constructor.
	* @aparam The reference to the engine observer
	*/
	CRpsGameEngine(MEngineObserver& aObs);
	
private:			
	
	/**
	* Called by the periodic timer on every heartbeat.
	* Checks user input, updates the graphics accordingly.
	*/		
	void GameLoop();
	
private:
	/**
	* The engine observer (to notify when screen updates are needed)
	*/
	MEngineObserver& iObs;
	
	/**
	* Timer for the game loop
	*/
	CPeriodic* iPeriodicTimer;
	
	/**
	* The inactivity timer
	*/
	CInactivityTimer* iInactivity;
	
	/**
	* Manages an array of game screens
	*/
	CGameScreenManager* iGameScreenMgr;
		
	};

#endif // __RPSGAMEENGINE_H__

// End of File

⌨️ 快捷键说明

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