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

📄 example3dcontainer.cpp

📁 一个基于symbian s60 3rd 的3D汽车游戏演示程序,模拟器上编译通过。
💻 CPP
字号:
   /*
============================================================================
    * Name : Example3DContainer.cpp
    * Part of : Example3D
    * Description : Definition of Example3DContainer
    * Copyright (c) 2007 Nokia Corporation
============================================================================
    */

// INCLUDE FILES
#include "Example3DContainer.h"
#include "CEngine.h"
#include "Example3D.hrh"
#include <eikmenub.h>
#include <eikspane.h>
#include <eikbtgpc.h>
#include <eiktbar.h>
#include <aknutils.h> 

void CExample3DContainer::ConstructL( const TRect& aRect )
    {
    CreateWindowL();
    iEngine = CEngine::NewL( SystemGc(), Window(),
                             CCoeEnv::Static()->ScreenDevice()->DisplayMode()
                             );
    ControlEnv()->AddForegroundObserverL( *this );
    // Start in  fullscreen because of problem issue in 3.0 openGL 
    SetExtentToWholeScreen();
    iFullScreen = 1;
    ActivateL();
    iEngine->Start();
    iEngine->DoGameFrameL();
    }



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



void CExample3DContainer::SizeChanged()
    {
    }

void CExample3DContainer::HandleResourceChange(TInt aType)
    {
    CCoeControl::HandleResourceChange(aType);
    
    if (iFullScreen)
        {
      SetExtentToWholeScreen();
        }
    else
        {
        if (aType == KEikDynamicLayoutVariantSwitch)
            {
            TRect mainPaneRect;
            AknLayoutUtils::LayoutMetricsRect(
                AknLayoutUtils::EMainPane, mainPaneRect );        
            SetRect(mainPaneRect);
            }
        }
    }

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;
    }


void CExample3DContainer::Command( TInt aCommand )
    {
    if( aCommand == EExample3DFullScreen )
        {
        iFullScreen ^= 1;
        if( iFullScreen )
            {
            SetExtentToWholeScreen();
            }
        else
            {
            TRect rect = CEikonEnv::Static()->EikAppUi()->ClientRect();
            SetRect(rect);
            }
        }
    else
        {
        iEngine->Command( aCommand );
        }
    }

⌨️ 快捷键说明

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