【发布时间】:2014-02-28 22:43:14
【问题描述】:
我非常沮丧,因为我无法像 Flappy Bird 中那样绘制地面... 我尝试使用这种方法:
private void drawGround(){
for(Rectangle mRectangleGroundHelper : mArrayGround){
if(spawnGround & mRectangleGroundHelper.x<0){ // spawn Ground if the actual ground.x + ground.width() is smaller then the display width.
mArrayGround.add(mRectangleGroundHelper);
spawnGround = false;
}
}
for(Rectangle mRectangleGroundHelper : mArrayGround){
if(mRectangleGroundHelper.x < -mTextureGround.getWidth()){ // set boolean to true, if the actual ground.x completely hide from display, so a new ground can be spawn
spawnGround = true;
}
}
for(Rectangle mRectangleGroundHelper : mArrayGround){ // move the ground in negative x position and draw him...
mRectangleGroundHelper.x-=2;
mStage.getSpriteBatch().draw(mTextureGround, mRectangleGroundHelper.x, mRectangleGroundHelper.y);
}
}
曾经的结果是,当 ground.x 从显示屏击中左侧时,地面在负 x 处移动得更快。那么我的方法有什么错误呢?
【问题讨论】:
-
通常,您会使用诸如 androidengine 或 libgdx 之类的引擎来执行诸如 flappy bird 之类的事情。
-
或者甚至在 Unity 之类的东西中构建它......
-
我用 Libgdx 开发它...
标签: java android libgdx game-physics flappy-bird-clone