?? explosionarray.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 + -