我想知道如何每秒将 1 添加到我的 int 中,直到在这种情况下达到某个数字 15。
但是我只希望在按下按钮后 int 开始增加。
@Override
public void touchUp(InputEvent event, float x, float y,
int pointer, int button) {
login.addAction(Actions.moveTo(0, 310, 1));
loginClicked = true;
if(loginClicked == true && loginTimer == 15){
login.addAction(Actions.moveTo(0, 430, 1));
}
}
});
Run Code Online (Sandbox Code Playgroud)
有我的代码,如您所见,我正在移动一些东西,如果它保持不变,则在 15 秒后我希望它也移动回来。
因此,当我制作一个三维三角形时,它只是错过了如下图所示的面部(四边形)我尝试的任何形状都会错过面部,你可以直接看到,(介意这是我第一次使用OpenGL和GLFW)
形状代码来自一个教程,因为我尝试了很多形状代码,看看是否是问题,似乎不是.

#include <glfw3.h>
#include <stdio.h>
#include <iostream>
using namespace std;
/* Begin Void prototyping */
void error_callback(int error, const char* description);
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
int main(void)
{
GLFWwindow* window;
/* Initializes error call-backs */
glfwSetErrorCallback(error_callback);
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); // fullscreen glfwGetPrimaryMonitor() (first NULL)
if (!window) …Run Code Online (Sandbox Code Playgroud) 我试图让我的FPS显示在窗口标题中,但是我的程序却没有它。
我的FPS代码
void showFPS()
{
// Measure speed
double currentTime = glfwGetTime();
nbFrames++;
if ( currentTime - lastTime >= 1.0 ){ // If last cout was more than 1 sec ago
cout << 1000.0/double(nbFrames) << endl;
nbFrames = 0;
lastTime += 1.0;
}
}
Run Code Online (Sandbox Code Playgroud)
我也希望它在版本之后
window = glfwCreateWindow(640, 480, GAME_NAME " " VERSION " ", NULL, NULL);
Run Code Online (Sandbox Code Playgroud)
但是我不能只将void ii转换为char?或者是什么 ?
所以我有我的双倍计算距离
double calculate2DDistance(int x1, int y1, int x2, int y2)
{
return sqrt((x2 - x1)^2 + (y2 - y1)^2);
}
Run Code Online (Sandbox Code Playgroud)
注意我正在从一个名为math.h的标题中调用此方法到我的主文件中
我在main.h中的测试行
cout << calculate2DDistance(2.0, 4.0, 3.0, 1.0) << endl;
Run Code Online (Sandbox Code Playgroud)
它打印出完全错误的答案或-1.#IND
这是怎么回事 ?