mopoidpanel.cpp
来自「mopoid game symbian os application devel」· C++ 代码 · 共 63 行
CPP
63 行
/*
========================================================================
Name : MopoidPanel.cpp
Author :
Copyright :
Description : Handles the panel ("avatar" of the player).
License :
========================================================================
*/
#include "MopoidPanel.h"
// --- TPanel
TPanel::TPanel()
:
iPos(0,0),
iX(0),
iVx(0),
iSettings(NULL)
{}
// -----------------------------------------------------------------------
void TPanel::SetSettingsPointer(CMopoidSettings* aSettings)
{
iSettings = aSettings;
}
// -----------------------------------------------------------------------
void TPanel::KeyboardMove(MopoidShared::TDirection aDirection)
{
TInt leftRight = 0;
if (aDirection == MopoidShared::ELeft)
leftRight = -1;
else if (aDirection == MopoidShared::ERight)
leftRight = 1;
iVx = iSettings->iPanelSpeed * (TReal)leftRight;
}
// -----------------------------------------------------------------------
void TPanel::SetSpeed(TReal aSpeed)
{
iVx = aSpeed;
}
// -----------------------------------------------------------------------
void TPanel::ConvertToPos(TReal aStep)
{
iX += iVx * aStep;
// Make sure that the panel doesn't go outside of the screen.
if (iX < iSettings->iGameRect.iTl.iX)
iX = iSettings->iGameRect.iTl.iX;
else if (iX + iSettings->iPanelSize.iWidth > iSettings->iGameRect.iBr.iX)
iX = iSettings->iGameRect.iBr.iX - iSettings->iPanelSize.iWidth;
// Convert new exact position to the screen position for faster calculations
iPos.iX = (TInt)iX;
// Don't move again unless we're told to.
iVx = 0.0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?