examples/SFExamples/games_on_symbian_os_code/vibrapool/src/moveball.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:  Class to animate the pool ball on the pool table.
00015 // 
00016 // 
00017 
00018 
00019 #include "moveball.h"
00020 
00021 const TInt KGenerationInterval = 10000;
00022 
00023 
00024 CMoveBall* CMoveBall::NewL(MUpdateContainer& aUpdater)
00025         {
00026         CMoveBall* self = new (ELeave) CMoveBall(aUpdater);
00027         CleanupStack::PushL(self);
00028         self->ConstructL();
00029         CleanupStack::Pop();
00030         return self;
00031         }
00032 
00033 CMoveBall::CMoveBall(MUpdateContainer& aUpdater) : 
00034                                                                 CTimer(CActive::EPriorityStandard),
00035                                                                 iUpdater(aUpdater)
00036         {       
00037         }
00038         
00039 CMoveBall::~CMoveBall()
00040         {
00041     if(IsActive())
00042             Cancel();
00043         }
00044         
00045 void CMoveBall::ConstructL()
00046         {
00047         // Contruct the timer and add this class to the active schedular to
00048         // manage its asynchronous behavior.
00049         CTimer::ConstructL();
00050         CActiveScheduler::Add(this);    
00051         }
00052 
00056 void CMoveBall::StartMovingBall()
00057         {
00058         // Give a 10 millisecond interval between consecutive screen updates
00059         After(TTimeIntervalMicroSeconds32(0));
00060         }
00061 
00065 void CMoveBall::StopMoveBall()
00066         {
00067         // Check if the animation is active and running via the timer
00068         if(IsActive())
00069                 {
00070                 CTimer::Cancel();       
00071                 Cancel();       
00072                 }
00073         }
00074         
00075 void CMoveBall::RunL()
00076         {
00077         // Give a 10 millisecond interval between consecutive screen updates
00078         After(TTimeIntervalMicroSeconds32(KGenerationInterval));
00079         // A callback to update the screen in the view class
00080         iUpdater.UpdateScreen();
00081         }
00082 
00083 void CMoveBall::DoCancel()
00084         {
00085         CTimer::DoCancel();     
00086         }

Generated by  doxygen 1.6.2