Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 使用SFML1.6,计算按钮按下次数的最佳方法是什么?_Loops_Count_Keypress_Sfml - Fatal编程技术网

Loops 使用SFML1.6,计算按钮按下次数的最佳方法是什么?

Loops 使用SFML1.6,计算按钮按下次数的最佳方法是什么?,loops,count,keypress,sfml,Loops,Count,Keypress,Sfml,例如: int count; //Code to count key presses here sf::String String("You have pressed a key this many times: " + count ); 我已经知道如何将int转换为字符串并插入它。使用事件: #include <SFML/Graphics.hpp> int main() { // Create the main window sf::RenderWindow

例如:

int count;

//Code to count key presses here

sf::String String("You have pressed a key this many times: " + count );
我已经知道如何将int转换为字符串并插入它。

使用事件:

#include <SFML/Graphics.hpp>
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    int count = 0;
    while (window.IsOpened())
    {
        sf::Event event;
        while (window.GetEvent(event))
        {
            if (event.Type == sf::Event::Closed)
                window.Close();
            if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::A)
                ++count;
        }
        window.Clear();
        // Do whatever you want with count.
        window.Display();
    }
    return 0;
}
#包括
int main()
{
//创建主窗口
sf::RenderWindow窗口(sf::VideoMode(800600),“SFML窗口”);
整数计数=0;
while(window.IsOpened())
{
sf::事件;
while(window.GetEvent(event))
{
如果(event.Type==sf::event::Closed)
window.Close();
if(event.Type==sf::event::KeyPressed&&event.Key.Code==sf::Key::A)
++计数;
}
window.Clear();
//伯爵,你想怎么做都行。
window.Display();
}
返回0;
}