当前位置: 首页>>代码示例>>C++>>正文


C++ Tooltip::draw方法代码示例

本文整理汇总了C++中Tooltip::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Tooltip::draw方法的具体用法?C++ Tooltip::draw怎么用?C++ Tooltip::draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tooltip的用法示例。


在下文中一共展示了Tooltip::draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
                    Game::clearEntities();
                    Game::clearTowers();
                    Game::life = 20;
                    Game::money = 1500;
                    Game::tickCount = 0;
                }
                break;
            case sf::Event::KeyReleased:
                keys[ev.key.code] = false;
                break;
            case sf::Event::MouseButtonPressed:
                SetFocus(window.getSystemHandle());
                if(ev.mouseButton.button == sf::Mouse::Left) {
                    Vec2i p = Vec2i(mouse.x,mouse.y)/Game::pixelsPerSquare;
                    if(Game::map.size()>p.x && p.x>=0
                            && Game::map[p.x].size()>p.y && p.y>=0) {
                        bool mustDeselect = true;
                        if(Game::map[p.x][p.y] == Game::TileType::EmptyTile) {
                            if(placingTower != nullptr && Game::money >= placingTower->cost) {
                                Game::money -= placingTower->cost;
                                Tower* t = placingTower->model->clone();
                                t->setPosition(p);
                                if(!Game::putTower(t))
                                    delete t;
                                else
                                    mustDeselect = false;
                            }
                        } else if(Game::map[p.x][p.y] == Game::TileType::TowerTile) {
                            Game::selectedTower = Game::getTower(Vec2i(mouse.x,mouse.y)/Game::pixelsPerSquare);
                            mustDeselect = false;
                        }
                        if(mustDeselect)
                            Game::selectedTower = nullptr;
                    }
                    placingTower = nullptr;
                } else if(ev.mouseButton.button == sf::Mouse::Right) {
                    Vec2i p = Vec2i(mouse.x,mouse.y)/Game::pixelsPerSquare;
                    if(Game::map[p.x][p.y] == Game::TileType::TowerTile) {
                        Tower* t = Game::removeTower(p);
                        if(t==nullptr) {
                            cout << "ERROR DELETING TOWER" << endl;
                        } else {
                            Game::money += Game::towerManager->getTowerCost(t->getId());
                            delete t;
                        }
                    }
                }
                break;
            default:
                break;
            }

            TowerType* tt = Game::towerManager->parseEvent(ev, mouse, sf::Vector2i(towersPanel.left,towersPanel.top));
            if(ev.type==sf::Event::MouseMoved)
                setTooltip(tooltip, mouse, tt);
            else if(tt!=nullptr) {
                if(tt->cost <= Game::money)
                    placingTower = tt;
            }

        }

        window.clear();
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();

        window.pushGLStates();
        sf::RectangleShape rect;
        rect.setOutlineColor(sf::Color::White);
        rect.setOutlineThickness(1);
        rect.setFillColor(sf::Color::Green);
        rect.setPosition(upgradesPanel.left, upgradesPanel.top);
        rect.setSize(sf::Vector2f(upgradesPanel.width, upgradesPanel.height));
        window.draw(rect);
        window.popGLStates();

        Game::towerManager->drawTowersPanel(&window, sf::Vector2i(towersPanel.left,towersPanel.top));

        Game::draw(&window);

        if(placingTower!=nullptr) {
            placingTower->model->draw(&window, mouse);
            placingTower->model->drawOver(&window, mouse);
        }

        if(tooltip!=nullptr)
            tooltip->draw(&window);

        window.display();

        this_thread::sleep_for(chrono::milliseconds(10));

        if(!paused) {
            if(Game::tick())
                running = false;
        }
    }
    window.close();
    freeGame();
}
开发者ID:ivancea,项目名称:TowerDefense,代码行数:101,代码来源:main.cpp


注:本文中的Tooltip::draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。