📄 infotextfx.cpp
字号:
/**
* File : InfoTextFX.cpp
* Author : Kevin Lynx
* Date : 2007/8/3
*/
#include "stdafx.h"
#include "InfoTextFX.h"
const f32 DEFAULT_SPEED = 100.0f;
InfoTextFX::InfoTextFX()
{
mDevice = 0;
mTexture = 0;
}
InfoTextFX::~InfoTextFX()
{
}
void InfoTextFX::init( IrrlichtDevice *device, ITexture *texture )
{
mTexture = texture;
mDevice = device;
dimension2d<s32> imgSize = mTexture->getSize();
mSrcRect.LowerRightCorner.X = imgSize.Width;
mSrcRect.LowerRightCorner.Y = imgSize.Height;
mSrcRect.UpperLeftCorner.X = 0;
mSrcRect.UpperLeftCorner.Y = 0;
dimension2d<s32> scrSize = mDevice->getVideoDriver()->getScreenSize();
mCenterPos.X = scrSize.Width / 2;
mCenterPos.Y = scrSize.Height / 2;
mLeftX = (f32)mCenterPos.X;
mUpY = (f32)mCenterPos.Y;
mEndLeftX = (f32)scrSize.Width / 4;
mSpeed = DEFAULT_SPEED;
}
void InfoTextFX::reset()
{
mLeftX = (f32)mCenterPos.X;
mUpY = (f32)mCenterPos.Y;
}
bool InfoTextFX::update( float dt )
{
if( mLeftX > mEndLeftX )
{
float add = mSpeed * dt;
mLeftX -= add;
mUpY -= add * mSrcRect.LowerRightCorner.Y / mSrcRect.LowerRightCorner.X ;
if( mLeftX <= mEndLeftX )
{
return true;
}
}
else
{
return true;
}
return false;
}
void InfoTextFX::render()
{
rect<s32> destRect( (int)mLeftX, (int)mUpY, int( mCenterPos.X + mCenterPos.X - mLeftX ),
int( mCenterPos.Y + mCenterPos.Y - mUpY ) );
mDevice->getVideoDriver()->draw2DImage( mTexture, destRect, mSrcRect, 0, 0, true );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -