本文整理汇总了C++中sf::View::Move方法的典型用法代码示例。如果您正苦于以下问题:C++ View::Move方法的具体用法?C++ View::Move怎么用?C++ View::Move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::View
的用法示例。
在下文中一共展示了View::Move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessAppEvents
void ProcessAppEvents(sf::RenderWindow &App, sf::View &v, GroupManager &gm)
{
sf::Event Event;
while (App.GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed: App.Close(); break;
case sf::Event::KeyPressed:
{
switch (Event.Key.Code)
{
case sf::Key::Escape: App.Close(); break;
case sf::Key::Right:
case sf::Key::Left:
case sf::Key::Up:
case sf::Key::Down:
{
const int step = 5;
v = App.GetView();
int hor = 0, ver = 0;
if (Event.Key.Code == sf::Key::Left)
hor+=step;
if (Event.Key.Code == sf::Key::Right)
hor-=step;
if (Event.Key.Code == sf::Key::Up)
ver+=step;
if (Event.Key.Code == sf::Key::Down)
ver-=step;
v.Move(hor, ver);
App.SetView(v);
break;
}
case sf::Key::S:
case sf::Key::D:
{
//if (Event.Key.Code == sf::Key::S)
// wanna_step_per_second-= wanna_step_per_second/10 - 1;
//if (Event.Key.Code == sf::Key::D)
// wanna_step_per_second+= wanna_step_per_second/10 + 1;
//if (wanna_step_per_second <= 0)
// step_per_second = 1;
//if (wanna_step_per_second >= 250)
// step_per_second = 250;
//step_time = 1.0/wanna_step_per_second;
break;
}
case sf::Key::W:
case sf::Key::E:
{
if (Event.Key.Code == sf::Key::E)
gm.SetStepSize(gm.GetStepSize() + 0.005);
if (Event.Key.Code == sf::Key::W)
gm.SetStepSize(gm.GetStepSize() - 0.005);
break;
}
case sf::Key::Z:
case sf::Key::X:
{
if (Event.Key.Code == sf::Key::Z)
v.Zoom(1.01);
if (Event.Key.Code == sf::Key::X)
v.Zoom(1.0/1.01);
break;
}
case sf::Key::A:
{
step_mode = (STEP_MODE) ((int)SM_HARD_STEPS_CNT + (int)SM_FREE_STEPS_CNT - step_mode);
break;
}
default: break;
}
break;
}
case sf::Event::Resized:
{
int h = Event.Size.Height;
int w = Event.Size.Width;
v.SetHalfSize(w/2, h/2);
break;
}
default: break;
}
}
}