本文整理汇总了C++中Sprite::GetRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::GetRotation方法的具体用法?C++ Sprite::GetRotation怎么用?C++ Sprite::GetRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::GetRotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PPCollisionWR
bool PPCollisionWR(Sprite Sprite1,Sprite Sprite2,float AlphaLimit = 50.f)
{
float xmin1 = Sprite1.GetPosition().x - Sprite1.GetCenter().x;
float ymin1 = Sprite1.GetPosition().y - Sprite1.GetCenter().y;
float xmin2 = Sprite2.GetPosition().x - Sprite2.GetCenter().x;
float ymin2 = Sprite2.GetPosition().y - Sprite2.GetCenter().y;
float xmax1 = xmin1 + Sprite1.GetSize().x;
float ymax1 = ymin1 + Sprite1.GetSize().y;
float xmax2 = xmin2 + Sprite2.GetSize().x;
float ymax2 = ymin2 + Sprite2.GetSize().y;
float xmin = max(xmin1, xmin2);
float ymin = max(ymin1, ymin2);
float xmax = min(xmax1, xmax2);
float ymax = min(ymax1, ymax2);
//if(xmax <= xmin || ymax <= ymin) { return false; }
for(int y = int(ymin); y < ymax; ++y)
{
for(int x = int(xmin); x < xmax; ++x)
{
float x1 = x - xmin1, y1 = y - ymin1;
float x2 = x - xmin2, y2 = y - ymin2;
Vector2f Point1 =
RotatePoint(Vector2f(x1,y1),
Sprite1.GetCenter(),
-Sprite1.GetRotation());
Vector2f Point2 =
RotatePoint(Vector2f(x2,y2),
Sprite2.GetCenter(),
-Sprite2.GetRotation());
if(Point1.x > 0 && Point1.y > 0 && Point2.x > 0 && Point2.y > 0
&& Point1.x < Sprite1.GetSize().x && Point1.y < Sprite1.GetSize().y
&& Point2.x < Sprite2.GetSize().x && Point2.y < Sprite2.GetSize().y)
{
Color color1 = Sprite1.GetPixel(int(Point1.x),int(Point1.y));
Color color2 = Sprite2.GetPixel(int(Point2.x),int(Point2.y));
if (color1.a >= AlphaLimit && color2.a >= AlphaLimit)
{
return true;
}
}
}
}
return false;
}
示例2: MoveSprites
void Sprites::MoveSprites(float timeStep)
{
Graphics* graphics = GetSubsystem<Graphics>();
float width = (float)graphics->GetWidth();
float height = (float)graphics->GetHeight();
// Go through all sprites
for (unsigned i = 0; i < sprites_.Size(); ++i)
{
Sprite* sprite = sprites_[i];
// Rotate
float newRot = sprite->GetRotation() + timeStep * 30.0f;
sprite->SetRotation(newRot);
// Move, wrap around rendering window edges
Vector2 newPos = sprite->GetPosition() + sprite->GetVar(VAR_VELOCITY).GetVector2() * timeStep;
if (newPos.x_ < 0.0f)
newPos.x_ += width;
if (newPos.x_ >= width)
newPos.x_ -= width;
if (newPos.y_ < 0.0f)
newPos.y_ += height;
if (newPos.y_ >= height)
newPos.y_ -= height;
sprite->SetPosition(newPos);
}
}
示例3: lua_Sprite_GetRotation
static int lua_Sprite_GetRotation(lua_State* state)
{
Sprite* sprite = LuaState::GetFuncParam<Sprite>(state, 1);
if(sprite == NULL)
{
return 0;
}
lua_pushnumber(state, sprite->GetRotation());
return 1;
}