本文整理汇总了C++中View::GetView方法的典型用法代码示例。如果您正苦于以下问题:C++ View::GetView方法的具体用法?C++ View::GetView怎么用?C++ View::GetView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::GetView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: level_execute
bool level_execute(level_str* level_info, sf::RenderWindow* window)
{
auto resource = make_shared<ResourceManager>();
auto config = resource->get_json("conf.json");
auto style = sf::Style::Default;
bool win = false;
Ground ground(resource, level_info->name);
Object people = {};
Object front_print = {};
Interactives interact(resource, level_info->name);
int levelJump = 0;
auto level = resource->get_json("levels/"+ level_info->name+".json");
View view = (sf::FloatRect((float)0,
(float)(SCREEN_Y_PXSIZE - ((int)(*level)["background"]["world"]["y"]) * BLOCK_PXSIZE),
(float)(((int)(*level)["background"]["world"]["x"]) * BLOCK_PXSIZE),
(float)(((int)(*level)["background"]["world"]["y"]) * BLOCK_PXSIZE)));
Background background(resource, level_info->name, sf::IntRect(0,
0,
((int)(*level)["background"]["world"]["x"]) * BLOCK_PXSIZE,
((int)(*level)["background"]["world"]["y"]) * BLOCK_PXSIZE));
auto font = resource->get_font(MATHLETE);
auto song = resource->get_music(SONG_1);
int ground_level = (*level)["ground"]["level"];
song->setLoop(true);
Text text((string)"SuperTeacher", sf::Vector2f(-60, -25) + view.GetView().getCenter(), font);
std::shared_ptr<sf::Text> timetext = make_shared<sf::Text>("Clock: " + to_string(Timer::get_time_ms()), *font, 100);
text.Add_Text(timetext, sf::Vector2f(-1500, -25) + view.GetView().getCenter());
std::array<std::array<int, 18>, 32> ColisionDetect = {};
const int SOLID = 1;
window->setMouseCursorVisible(false);
window->setFramerateLimit(50);
HIManager user_input = { window };
user_input.HIEvent_sig.connect([level_info,&view](HIEvent event)->void {
static float factor = 1;
switch (event) {
case HIEvent::CLOSE:
level_info->end = true;
break;
case HIEvent::DOWN_DOWN:
if (factor <= 1.6)
{
factor += 0.3;
}
else
{
factor = 1;
}
view.SetSize(sf::Vector2f(factor*SCREEN_X_PXSIZE, factor*SCREEN_Y_PXSIZE));
break;
default:
break;
}
});
std::shared_ptr<sf::Text> score = make_shared<sf::Text>("Points: ", *font, 50);
text.Add_Text(score, sf::Vector2f(-900, -25) + view.GetView().getCenter());
std::shared_ptr<sf::Text> live = make_shared<sf::Text>("Lives: ", *font, 50);
text.Add_Text(live, sf::Vector2f(-60, -75) + view.GetView().getCenter());
for (int y = 17; y >= ground_level; y--) {
for (int x = 0; x < 32; x++) {
ColisionDetect[x][y] = SOLID;
}
}
std::string gr_name = (*level)["ground"]["name"];
auto character = Character(resource, level_info->name, ground_level);
character.addPencil((*level)["init"]["pencil"]);
std::shared_ptr<sf::Text> pencil = make_shared<sf::Text>("Pencils: " + to_string(character.getNbPencil()), *font, 50);
text.Add_Text(pencil, sf::Vector2f(-900, -75) + view.GetView().getCenter());
user_input.HIEvent_sig.connect([&character,&level_info](HIEvent event)->void {
character.process_event(event,&level_info->score);
});
if ((bool)(*config)["audio"]) {
song->play();
}
colision col = { true,true,ground_level*BLOCK_PXSIZE,0 };
while (!level_info->end)
{
*level_info = interact.update(character, score, ground_level*BLOCK_PXSIZE, &col,&level_info->score);
//.........这里部分代码省略.........