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

📄 explosionarray.cpp

📁 s60源码
💻 CPP
字号:
/**
 *
 * @brief Definition of CExplosionArray
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

//Class Include
#include "ExplosionArray.h"

// System Include
#include <e32math.h>

// User Include
#include "Explosion.h"

const TInt KAreaOfImage = 16;


CExplosionArray* CExplosionArray::NewL(const TRect aValidArea)
	{
	CExplosionArray* self = CExplosionArray::NewLC(aValidArea);
	CleanupStack::Pop();
	return self;
	}

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

CExplosionArray::CExplosionArray(const TRect aValidArea) :
	iValidArea(aValidArea)
	{
	}

CExplosionArray::~CExplosionArray()
	{
	iExplosionsArray.ResetAndDestroy();
	iExplosionsArray.Close();
	}

void CExplosionArray::ConstructL()
	{
	}

void CExplosionArray::CreateExplosionL()
	{
	TInt x = 0;
	TInt y = 0;
	GenerateRandomPosition(x, y);
	CExplosion* explosion = CExplosion::NewLC(TPoint(x,y)); // created using NewLC because it is an automatic not member data
	CleanupStack::Pop();
	iExplosionsArray.Append(explosion);
	}

void CExplosionArray::DrawExplosions(CBitmapContext& aBitmapContext)
	{
	TInt currentExplosion = 0;
	TInt sizeOfArray = iExplosionsArray.Count();

	while(currentExplosion < sizeOfArray)
		{
		if(iExplosionsArray[currentExplosion]->IsFinished())
			{
			delete iExplosionsArray[currentExplosion];
			iExplosionsArray.Remove(currentExplosion);
			iExplosionsArray.Compress();
			sizeOfArray--;
			}
		else
			{
			iExplosionsArray[currentExplosion]->BlitCurrentFrame(aBitmapContext);
			currentExplosion++;
			}
		}
	}

void CExplosionArray::GenerateRandomPosition(TInt& aX, TInt& aY)
	{
	TTime randomTime;
	randomTime.HomeTime();
	TInt64 seed = randomTime.Int64();
	TInt randomX = Math::Rand(seed);
	TInt randomY = Math::Rand(seed);

	aX = randomX % iValidArea.Width();
	aY = randomY % iValidArea.Height();
	}

// End of File

⌨️ 快捷键说明

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