我让我的纹理像减少它的X轴一样移动。但问题是,当我以更快的速度移动它时,它没有正确地添加。我的示例代码如下所示。
picx = 0;
newpicx = 1024;
if(speed<20) speed+=.05f;
picx -=speed;
newpicx -= speed;
if ((picx + 1024 - speed-4) <0) {
picx = 1024;
}
if ((newpicx + 1024 - speed-4) <0) {
newpicx = 1024;
}发布于 2014-01-10 15:08:35
你的代码没有多大意义,但这是我的尝试:
picx = 0;
newpicx = 1024;
if(speed<20) speed+=.05f;
picx -=speed;
newpicx -= speed;
if ((picx + 1024 - speed-4) <0) {
picx = 1024;
}
if ((newpicx + 1024 - speed-4) <0) {
newpicx = 1024;
}你正在制作两个“图片”,不管它是什么,它们的x位置开始于1st=0,2nd=1024。然后使用稳定在20的递增速度向左移动它们(负x),当它们在x轴上低于0超过1024个单位时,它们传送到正1024。
当你开始增加他们的x,而不是减少时,你就会有问题。这是因为当它们是+1024单位正x时,你没有处理。
picx +=speed*delta; //use delta for FrameIndependant Movement
newpicx += speed*delta;
if (picx > 1024){
picx = -1024;
}
if (newpicx > 1024){
newpicx = -1024;
}https://stackoverflow.com/questions/15061619
复制相似问题