example3dcontainer.cpp

来自「This package includes a 3-D game engine 」· C++ 代码 · 共 82 行

CPP
82
字号
    /*
    *
============================================================================
    *  Name     : CExample3DContainer.cpp
    *  Part of  : Example3D
    *  Created  : 12/14/2003 by Forum Nokia
    *  Description:
    *     This is the project specification file for Example3D.
    *     Initial content was generated by Series 60 AppWizard.
    *
    *  Version  : 1.0.0
    *  Copyright: Forum Nokia
    *
============================================================================
    */


// INCLUDES
#include "Example3DContainer.h"
#include "CEngine.h"
#include <eikenv.h>

// MEMBER FUNCTIONS

void CExample3DContainer::ConstructL( const TRect& /*aRect*/ )
    {

    CreateWindowL();

	iEngine = CEngine::NewL( SystemGc(), Window(),
							 CCoeEnv::Static()->ScreenDevice()->SizeInPixels(),
							 CCoeEnv::Static()->ScreenDevice()->DisplayMode()
							 );

	SetExtentToWholeScreen();
    ActivateL();

	ControlEnv()->AddForegroundObserverL( *this );
	iEngine->Start();
    }


CExample3DContainer::~CExample3DContainer()
    {
	ControlEnv()->RemoveForegroundObserver( *this );
	delete iEngine;
    }


void CExample3DContainer::HandleGainingForeground()
	{
	iEngine->Start();
	}

void CExample3DContainer::HandleLosingForeground()
	{
	iEngine->Stop();
	}


TKeyResponse CExample3DContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	// Game's idle timer doesn't allow focuschange too easily,
	// this is to help it a little
	// So when application change key is pressed, the key event comes here
	// but the OS doesn't have enough time to change the application focus
	// This catches the application key press and leaves the thread for one second
	// In that time OS has all the time it needs to change focus.
	if( aKeyEvent.iScanCode == EStdKeyApplication0 )
		{
		User::After( 1000000 );
		return EKeyWasConsumed;
		}

	// In all other cases just forward the key presses to the game engine.
	iEngine->KeyEvent( aKeyEvent, aType );
	return EKeyWasConsumed;
	}



⌨️ 快捷键说明

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