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

📄 polytubeappview.cpp

📁 手机 GAME c++ 版
💻 CPP
字号:
////////////////////////////////////////////////////////////////////////
//
// PolyTubeAppView.cpp
//
// Copyright (c) 2003 Nokia Mobile Phones Ltd.  All rights reserved.
//
////////////////////////////////////////////////////////////////////////

#include "PolyTubeAppView.h"

#include <eikenv.h>

#include "PolyTubeEngine.h"

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

CPolyTubeAppView* CPolyTubeAppView::NewL(const TRect& aRect)
    {
    CPolyTubeAppView* self = CPolyTubeAppView::NewLC(aRect);
    CleanupStack::Pop();
    return self;
    }

////////////////////////////////////////////////////////////////////////

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

////////////////////////////////////////////////////////////////////////

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

    // Set the windows size
    SetRect(aRect);

	iEngine = CPolyTubeEngine::NewL(iEikonEnv->WsSession(), 
		*(CCoeEnv::Static()->ScreenDevice()), Window(), iKeyHandler, Rect().Size());
	
	// Activate the window, which makes it ready to be drawn
    ActivateL();

	iEngine->StartFirstGameL();
    }

////////////////////////////////////////////////////////////////////////

CPolyTubeAppView::CPolyTubeAppView() :
	iKeyHandler()
    {
    }

////////////////////////////////////////////////////////////////////////

CPolyTubeAppView::~CPolyTubeAppView()
    {
	delete iEngine;
    }

////////////////////////////////////////////////////////////////////////

void CPolyTubeAppView::Draw(const TRect& /*aRect*/) const
    {
    // Clear the screen
    CWindowGc& gc = SystemGc();
    gc.Clear(Rect());
    }

////////////////////////////////////////////////////////////////////////

TKeyResponse CPolyTubeAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	TKeyResponse returnKey = EKeyWasNotConsumed;

	// If the app switch key is pressed we need to stop drawing
	if(aType == EEventKey && aKeyEvent.iScanCode == EStdKeyApplication0)
		{
		StopGame();
		// we still want the key event to be passed on so don't consume the key
		}
	else if(aType == EEventKeyDown)
		{
		switch(aKeyEvent.iScanCode)
			{
			case EStdKeyLeftArrow:
				iKeyHandler.LeftPressed();
				returnKey = EKeyWasConsumed;
				break;
			case EStdKeyRightArrow:
				iKeyHandler.RightPressed();
				returnKey = EKeyWasConsumed;
				break;
			case EStdKeyDevice3:
				iKeyHandler.PressedFire();
				returnKey = EKeyWasConsumed;
				break;
		default:
			break;
			}
		}
	else if(aType == EEventKeyUp)
		{
		switch(aKeyEvent.iScanCode)
			{
			case EStdKeyLeftArrow:
				iKeyHandler.NoDirection();
				returnKey = EKeyWasConsumed;
				break;
			case EStdKeyRightArrow:
				iKeyHandler.NoDirection();
				returnKey = EKeyWasConsumed;
				break;
			case EStdKeyDevice3:
				iKeyHandler.FireReleased();
				returnKey = EKeyWasConsumed;
				break;
		default:
			break;
			}
		}

	return returnKey;

	}

////////////////////////////////////////////////////////////////////////

void CPolyTubeAppView::StartGameL()
	{
	iEngine->StartGameL();
	}

////////////////////////////////////////////////////////////////////////

void CPolyTubeAppView::StopGame()
	{
	iEngine->StopGame();
	}

////////////////////////////////////////////////////////////////////////

TBool CPolyTubeAppView::IsPlaying()
	{
	return iEngine->Playing();
	}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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