explosion.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 87 行

CPP
87
字号
/**
 *
 * @brief Definition of CExplosion
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

#include "Explosion.h"

#include <aknutils.h>

#include <ClientAnimation.mbg>

_LIT(KFramesPath, "\\system\\apps\\ClientAnimation\\ClientAnimation.mbm");
const TInt KMaxNumFrames = 4;

CExplosion* CExplosion::NewL(TPoint aPoint)
{
    CExplosion* self = CExplosion::NewLC(aPoint);
    CleanupStack::Pop();
    return self;
}

CExplosion* CExplosion::NewLC(TPoint aPoint)
{
    CExplosion* self = new (ELeave) CExplosion(aPoint);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CExplosion::CExplosion(TPoint aPoint) :
    iCurrentFrame(0),
    iPoint(aPoint),
    iDescending(EFalse)
{
}

CExplosion::~CExplosion()
{
    iBitmapArray.ResetAndDestroy();
    iMasksArray.ResetAndDestroy();
}

void CExplosion::ConstructL()
{
    CEikonEnv* env = CEikonEnv::Static();
    TFileName framesFile(KFramesPath);
    User::LeaveIfError(CompleteWithAppPath(framesFile));

    iBitmapArray.Append(env->CreateBitmapL(framesFile, EMbmClientanimationExplosionone));
    iBitmapArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosiontwo));
    iBitmapArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosionthree));
    iBitmapArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosionfour));
    iMasksArray.Append(env->CreateBitmapL(framesFile, EMbmClientanimationExplosiononemask));
    iMasksArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosiontwomask));
    iMasksArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosionthreemask));
    iMasksArray.Append(env->CreateBitmapL(framesFile,EMbmClientanimationExplosionfourmask));
}

TBool CExplosion::IsFinished()
{
    return iCurrentFrame == 0 && iDescending;
}

void CExplosion::BlitCurrentFrame(CBitmapContext& aBitmapContext)
{
    aBitmapContext.BitBltMasked(iPoint, iBitmapArray[iCurrentFrame], TRect(TPoint(0,0), iBitmapArray[iCurrentFrame]->SizeInPixels()), iMasksArray[iCurrentFrame], ETrue);

    if(iDescending)
    {
        iCurrentFrame--;
    }
    else
    {
        iCurrentFrame++;

        if(iCurrentFrame == KMaxNumFrames)
        {
            iDescending = ETrue;
            iCurrentFrame--;
        }
    }
}
// End of File

⌨️ 快捷键说明

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