本文整理汇总了C++中CLine::SetAlphaLossPerMs方法的典型用法代码示例。如果您正苦于以下问题:C++ CLine::SetAlphaLossPerMs方法的具体用法?C++ CLine::SetAlphaLossPerMs怎么用?C++ CLine::SetAlphaLossPerMs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLine
的用法示例。
在下文中一共展示了CLine::SetAlphaLossPerMs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewBulletTracer
void CParticleEngine::NewBulletTracer(int x1, int y1, int x2, int y2, float intensity)
{
int orderedTracerLength = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1) * (y2 - y1));
int createdTracerLength = 0;
bool firstLine = true;
float gradient = (float)(y2 - y1) / (float)(x2 - x1);
float lineSegmentLength = standardLineSegmentLength * intensity;
int loopNumber = 0;
//create a bunch of lines with decreasing color and alpha intensity
while (createdTracerLength < orderedTracerLength)
{
float angle = atan2(y2 - y1, x2 - x1);
float cosAngle = cos(angle);
float sinAngle = sin(angle);
CLine * line = new CLine();
if (firstLine)
{
firstLine = false;
line->x1 = x1;
line->y1 = y1;
}
else
{
//take first point coordinates from last line's second point coordinates
line->x1 = lineVector.at(lineVector.size() - 1)->x2 + cosAngle/abs(cosAngle);
line->y1 = lineVector.at(lineVector.size() - 1)->y2 + sinAngle/abs(sinAngle);
}
if (createdTracerLength + lineSegmentLength > orderedTracerLength) //last line is shorter
{
lineSegmentLength = orderedTracerLength - createdTracerLength;
}
/*x = old_x + length * cos(alpha);
y = old_y + length * sin(alpha);*/
//calculate x2 and y2
line->x2 = line->x1 + lineSegmentLength * cosAngle;
line->y2 = line->y1 + lineSegmentLength * sinAngle;
createdTracerLength += lineSegmentLength;
//set color values according to intensity
line->SetRGB(255, 255, 255 - (intensity*150.0f) + loopNumber * (8.0f / intensity));
line->SetAlpha(160 + (intensity*50.0f) - (loopNumber * (5.0f / intensity)));
line->SetAlphaLossPerMs(1.3f - intensity * 2);
loopNumber++;
lineVector.push_back(line);
}
}