本文整理汇总了C++中TextObject::setVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ TextObject::setVelocity方法的具体用法?C++ TextObject::setVelocity怎么用?C++ TextObject::setVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextObject
的用法示例。
在下文中一共展示了TextObject::setVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeText
void LetterHunter::initializeText()
{
ID2D1Factory* D2DFactory = d2d_->getD2DFactory();
ID2D1HwndRenderTarget* renderTarget = d2d_->getD2DHwndRenderTarget();
IDWriteFactory* DWriteFactory = d2d_->getDWriteFactory();
for(int i = 0; i < TEXTCOUNT; ++i)
{
// Geneate a random string
const int strLength = 1;
wchar_t* strBuffer = new wchar_t[strLength + 1];
randomString(strBuffer, strLength);
TextObject* textObj = new TextObject(
D2DFactory,
renderTarget,
DWriteFactory,
strBuffer,
100
);
SAFE_DELETE(strBuffer);
// Generate 10 random numbers between 1 and 100
float a[10] = {0};
float velocityY = randomFloat(10.0f, 50.0f);
D2D_VECTOR_2F velocity = {0, velocityY};
// Set text position
float windowWidth = (float)getwindowWidth();
D2D1_RECT_F textBoundRect = textObj->getBoundaryRect();
float maxRight = windowWidth - (textBoundRect.right -textBoundRect.left);
float positionX = randomFloat(0, maxRight);
D2D1_POINT_2F position = {positionX, 0};
textObj->setPosition(position);
// Set text velocity
textObj->setVelocity(velocity);
D2D1_COLOR_F fillColor = randomColor();
textObj->setFillColor(fillColor);
textBuffer_.push_back(textObj);
}
}