Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.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
Java 使用Fisica/Box2D处理时滚动背景_Java_Processing_Box2d_Jbox2d_Side Scroller - Fatal编程技术网

Java 使用Fisica/Box2D处理时滚动背景

Java 使用Fisica/Box2D处理时滚动背景,java,processing,box2d,jbox2d,side-scroller,Java,Processing,Box2d,Jbox2d,Side Scroller,我试图用Fisica(JBox2D端口)和Processing 3创建一个滚动世界。这个代码几乎可以正常工作,它可以正确地滚动等等,但是当我使用This.player跳转This.player.addImpulse(0,-150)时,它可以在世界没有滚动但跳跃高度大大降低的情况下工作。为什么会发生这种情况?有什么更好的方式可以滚动背景 public void xOffsetCalculations(){ 如果(player.getX()>width-(width/3)){ float off=w

我试图用Fisica(JBox2D端口)和Processing 3创建一个滚动世界。这个代码几乎可以正常工作,它可以正确地滚动等等,但是当我使用
This.player
跳转
This.player.addImpulse(0,-150)
时,它可以在世界没有滚动但跳跃高度大大降低的情况下工作。为什么会发生这种情况?有什么更好的方式可以滚动背景

public void xOffsetCalculations(){
如果(player.getX()>width-(width/3)){
float off=width-(width/3)-this.player.getX();
this.player.setPosition(width-(width/3),this.player.getY());
此.offset.x+=off;
}
if(player.getX()高度-(高度/4)){
float off=height-(height/4)-this.player.getY();
this.player.setPosition(this.player.getX(),height-(height/4));
此.offset.y+=off;
}
}
我已经把完整的代码,如果需要的话。不过,请注意,它很混乱,因为我刚刚将它从处理IDE移植到Eclipse

提前谢谢