我是C++的新手并且尝试学习游戏编程,我选择SFML并使用Jetbrain在CLion上运行并使用Ubuntu机器.我在这里学习SFML和Linux这个教程 我的代码:
#include <SFML/Graphics.hpp>
using namespace sf;
int main() {
RenderWindow window(sf::VideoMode(200, 200), "SFML Work!");
CircleShape shape(100.f);
shape.setFillColor(Color::Green);
while (window.isOpen()) {
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed) {
window.close();
}
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我在CLion上运行时出错了
CMakeFiles/SFMLBasic.dir/main.cpp.o: In function `main':
undefined reference to `sf::String::String(char const*, std::locale const&)'
undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
...
undefined reference to `sf::Shape::~Shape()'
Run Code Online (Sandbox Code Playgroud)
我如何配置或设置在CLion中运行SFML,我不知道CMAKE可以做到这一点?我只运行终端, …
我对Chrome DevTools中的这个符号(< - )感到困惑

它的返回值还是控制台价值?
当我循环运行时
var i = 0;
while (i < 5) {
console.log(i);
i++;
}
Run Code Online (Sandbox Code Playgroud)
控制台日志吐出4次,最后4次在前面有一个(< - ),这是什么意思?
我的项目在java swing上运行,有2个按钮(开始/停止)进行计数.
当我点击开始按钮.有一个线程正在运行(Thread-0),然后单击停止按钮"Thread-0"消失,但是当我多次单击开始按钮时.有许多线程,如Thread-5,Thread-6,.. Thread-10正在运行.
问题: 如果单击开始然后停止计数就可以了.但点击开始多次计数不正确.
开始按钮
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {
start();
btnStart.setEnabled(false);
btnStop.setEnabled(true);
}
Run Code Online (Sandbox Code Playgroud)
停止按钮
private void btnStopActionPerformed(java.awt.event.ActionEvent evt) {
isEnable = false;
btnStop.setEnabled(false);
btnStart.setEnabled(true);
}
Run Code Online (Sandbox Code Playgroud)
start()方法:
isEnable = true;
Thread refreshPlan = new Thread() {
@Override
public void run() {
while(isEnable) {
try {
sleep(CYCLE_TIME * 1000);
PLAN += 1;
planValue.setText(String.valueOf(PLAN));
} catch (InterruptedException ex) {
//ignore
}
}
};
};
refreshPlan.start();
Run Code Online (Sandbox Code Playgroud)
在开始按钮中多次单击时,我可以只运行单个线程吗?有什么建议吗?谢谢.
对不起,我的英语不好.