本文整理汇总了C++中Sprite::ApplyChange方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::ApplyChange方法的具体用法?C++ Sprite::ApplyChange怎么用?C++ Sprite::ApplyChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::ApplyChange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckForSpriteScaling
void LevelEditor::CheckForSpriteScaling()
{
if (mSelectedObject)
{
static bool pressingScale = false;
static Vector2 mouseStartPos = Vector2(0,0);
static Vector2 originalDimensions = Vector2(0,0);
if (!pressingScale && GetAsyncKeyState('X') < 0 && GetAsyncKeyState(VK_LBUTTON) < 0 && GetAsyncKeyState(VK_CONTROL) >= 0)
{
pressingScale = true;
POINT currentMouse;
GetCursorPos(¤tMouse);
ScreenToClient(DXWindow::GetInstance()->Hwnd(), ¤tMouse);
mouseStartPos = Vector2(currentMouse.x, currentMouse.y);
originalDimensions = Vector2(mSelectedObject->Dimensions().X, mSelectedObject->Dimensions().Y);
}
else if (pressingScale && GetAsyncKeyState(VK_LBUTTON) < 0)
{
// get the initial distance between the game object and the mouse
Vector2 origDistance = mouseStartPos - Vector2(mSelectedObject->X(), mSelectedObject->Y());
// origDistance = Vector2(abs(origDistance.X), abs(origDistance.Y));
float origLength = origDistance.Length();
// now get the distance between the current mouse position
POINT currentMouse;
GetCursorPos(¤tMouse);
ScreenToClient(DXWindow::GetInstance()->Hwnd(), ¤tMouse);
Vector2 newDistance = Vector2(currentMouse.x, currentMouse.y) - Vector2(mSelectedObject->X(), mSelectedObject->Y());
float newLength = newDistance.Length();
float scale = newLength / origLength;
if (scale != 0)
{
mSelectedObject->SetDimensionsXYZ(originalDimensions.X * scale, originalDimensions.Y * scale, mSelectedObject->Dimensions().Z);
Sprite * s = GetAsSprite(mSelectedObject);
if (s)
{
s->ScaleSpriteOnly(scale, scale);
s->SetIsNativeDimensions(false);
s->ApplyChange(Graphics::GetInstance()->Device());
}
}
}
if (GetAsyncKeyState('X') >= 0)
{
pressingScale = false;
mouseStartPos = Vector2(0,0);
originalDimensions = Vector2(0,0);
}
}
}
示例2: CheckForSettingNativeRes
void LevelEditor::CheckForSettingNativeRes()
{
if (mSelectedObject)
{
if (GetAsyncKeyState('N') < 0 && GetAsyncKeyState(VK_CONTROL) < 0)
{
Sprite * s = GetAsSprite(mSelectedObject);
if (s)
{
s->SetIsNativeDimensions(true);
s->ScaleSpriteOnly(1,1); // resets vertices and debug bounding box
s->ApplyChange(Graphics::GetInstance()->Device());
}
}
}
}
示例3: CheckInput_Regular
void LevelEditor::CheckInput_Regular()
{
list<shared_ptr<GameObject> > & gameObjects = GameObjectManager::Instance()->GetGameObjectList();
static bool pressingSelect = false;
static bool pressingPlace = false;
if (mSelectedObject)
{
if (!pressingSelect && GetAsyncKeyState(VK_RBUTTON) < 0 && GetAsyncKeyState('R') >= 0)
{
GameObject * obj = GetGameObjectClickedOn(gameObjects);
if (obj)
{
if (obj == mSelectedObject)
{
// deselect
mSelectedObject->ShowDebugText(false);
mSelectedObject->SetLevelEditShowSelected(false);
mSelectedObject = nullptr;
}
else
{
mSelectedObject->ShowDebugText(false);
mSelectedObject->SetLevelEditShowSelected(false);
mSelectedObject = obj;
mSelectedObject->ShowDebugText(true);
mSelectedObject->SetLevelEditShowSelected(true);
}
}
pressingSelect = true;
}
if (mSelectedObject)
{
if (GetAsyncKeyState(VK_LBUTTON) < 0 && GetAsyncKeyState('X') >= 0 && GetAsyncKeyState('C') >= 0 && GetAsyncKeyState('R') >= 0)
{
// drag
// get the mouse in world coordinates and set the game objects position
POINT currentMouse;
GetCursorPos(¤tMouse);
ScreenToClient(DXWindow::GetInstance()->Hwnd(), ¤tMouse);
// the backbuffer may be larger in size than the the window (Windows scaling) so scale accordingly
float scaleX = Graphics::GetInstance()->BackBufferWidth() / DXWindow::GetInstance()->GetWindowDimensions().X;
float scaleY = Graphics::GetInstance()->BackBufferHeight() / DXWindow::GetInstance()->GetWindowDimensions().Y;
Vector2 worldPos = Utilities::ScreenToWorld(Vector2(currentMouse.x * scaleX, currentMouse.y * scaleY));
mSelectedObject->SetX(worldPos.X);
mSelectedObject->SetY(worldPos.Y);
Sprite * sprite = GetAsSprite(mSelectedObject);
if (sprite)
{
sprite->ApplyChange(Graphics::GetInstance()->Device());
sprite->Update(0);
}
MovingSprite * movingSprite = GetAsMovingSprite(mSelectedObject);
if (movingSprite)
{
movingSprite->SetVelocityXYZ(0, 0, 0);
}
ScrollingSprite * scrollingSprite = GetAsScrollingSprite(mSelectedObject);
if (scrollingSprite)
{
scrollingSprite->SetLerpStartPos(worldPos);
}
SolidLineStrip * solidLineStrip = GetAsSolidLineStrip(mSelectedObject);
if (solidLineStrip)
{
vector<SolidLineStrip::SolidLinePoint> points = solidLineStrip->GetLinePoints();
solidLineStrip->RecalculateLines(points);
}
ParticleSpray * particleSpray = GetAsParticleSpray(mSelectedObject);
if (particleSpray)
{
particleSpray->Reset();
}
pressingPlace = true;
}
}
}
else
{
if (!pressingSelect && GetAsyncKeyState(VK_RBUTTON) < 0 && GetAsyncKeyState('R') >= 0)
{
mSelectedObject = GetGameObjectClickedOn(gameObjects);
if (mSelectedObject)
{
mSelectedObject->ShowDebugText(true);
mSelectedObject->SetLevelEditShowSelected(true);
}
//.........这里部分代码省略.........