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

📄 skiingcontainer.cpp

📁 最新官方例子,图形,描述副,基本控件,通讯协议,等等,
💻 CPP
字号:
/**
*
* @brief Definition of CSkiingContainer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "SkiingContainer.h"

// System includes
#include <eiklabel.h> // CEikLabel
#include <Skiing.rsg> // Resources
#include <stringloader.h> // StringLoader

#include <images.mbg>
#include <eikenv.h>

// CONSTANTS

const TInt KSkiFrameTime = 50000;


// Standard Epoc construction sequence
CSkiingContainer* CSkiingContainer::NewL(const TRect& aRect)
	{
	CSkiingContainer* self = CSkiingContainer::NewLC(aRect);
	CleanupStack::Pop();
	return self;
	}

CSkiingContainer* CSkiingContainer::NewLC(const TRect& aRect)
	{
	CSkiingContainer* self = new (ELeave) CSkiingContainer;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

void CSkiingContainer::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();

	// Set the window's size and position
	SetRect(aRect);

	iEngine = CSkiEngine::NewL(Rect());

	iRenderer = CSkiFrameRenderer::NewL(Size(), *iEngine);

	iDSAWrapper = CDSAWrapper::NewL(iEikonEnv->WsSession(), *(iEikonEnv->ScreenDevice()), Window());

	iLoop = CSkiGameLoop::NewL(*iEngine, *iRenderer, *iDSAWrapper);

	// Activate the window, which makes it ready to be drawn
	ActivateL();
	}

CSkiingContainer::CSkiingContainer()
	{
	}

CSkiingContainer::~CSkiingContainer()
	{
	StopDSA();

	delete iLoop;

	delete iEngine;
	delete iRenderer;
	delete iDSAWrapper;
	}

// Draw this application's view to the screen
void CSkiingContainer::Draw(const TRect& /*aRect*/) const
	{
	if (iLoop && !iLoop->IsActive())
		{
		// could display a title screen here instead
		CWindowGc& gc = SystemGc();
		gc.Clear(Rect());
		}
	}

void CSkiingContainer::StopDSA()
	{
	// Stop the timer if it is active
	if (iLoop && iLoop->IsActive())
		{
		iLoop->Cancel();
		}
	}


void CSkiingContainer::StartDSA()
	{
	iLoop->SetPaused(EFalse);

	StopDSA();

	// If the timer is not already running, start it
	if (!iLoop->IsActive())
		{
		iLoop->Start(KSkiFrameTime);
		}
	}

TKeyResponse CSkiingContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	TKeyHandler& keyHandler = iEngine->KeyHandler();

	if (iLoop && !iLoop->IsActive())
		{
		return EKeyWasNotConsumed;
		}


	if (aType == EEventKeyDown)
		{
		switch (aKeyEvent.iScanCode)
			{
			case EStdKeyLeftArrow:
			case EStdKeyNkp4:
			case '4':
				keyHandler.SetState(TKeyHandler::ELeft, ETrue);
				break;
			case EStdKeyRightArrow:
			case EStdKeyNkp6:
			case '6':
				keyHandler.SetState(TKeyHandler::ERight, ETrue);
				break;
			case EStdKeyDevice3:
			case EStdKeyNkp5:
			case '5':
				keyHandler.SetState(TKeyHandler::EFire, ETrue);
				break;
			default:
				break;
			}
		return EKeyWasConsumed;
		}
	else if (aType == EEventKeyUp)
		{
		switch (aKeyEvent.iScanCode)
			{
			case EStdKeyLeftArrow:
			case EStdKeyNkp4:
			case '4':
				keyHandler.SetState(TKeyHandler::ELeft, EFalse);
				break;
			case EStdKeyRightArrow:
			case EStdKeyNkp6:
			case '6':
				keyHandler.SetState(TKeyHandler::ERight, EFalse);
				break;
			case EStdKeyDevice3:
			case EStdKeyNkp5:
			case '5':
				keyHandler.SetState(TKeyHandler::EFire, EFalse);
				break;
			default:
				break;
			}
		return EKeyWasConsumed;
		}
	else
		{
		return EKeyWasNotConsumed;
		}
	}

⌨️ 快捷键说明

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