Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.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 文本超出摄影机边界_Java_Android_Andengine - Fatal编程技术网

Java 文本超出摄影机边界

Java 文本超出摄影机边界,java,android,andengine,Java,Android,Andengine,我正在安德林做一个问答游戏,游戏中有一个问题,答案在跳跃 但问题是游戏运行良好,但当使用肖像或定位时,我游戏的问题超出了摄像机的范围,因此半个问题只能阅读 如何将文本设置为适合摄影机宽度 mBitmapFont=FontFactory.createFromAsset(this.getFontManager(),this.getTextureManager(), 200222,TextureOptions.BILINEAR,this.getAssets(),“Plok.ttf”,32,true,C

我正在安德林做一个问答游戏,游戏中有一个问题,答案在跳跃 但问题是游戏运行良好,但当使用肖像或定位时,我游戏的问题超出了摄像机的范围,因此半个问题只能阅读

如何将文本设置为适合摄影机宽度

mBitmapFont=FontFactory.createFromAsset(this.getFontManager(),this.getTextureManager(),
200222,TextureOptions.BILINEAR,this.getAssets(),“Plok.ttf”,32,true,Color.WHITE);
问题=新文本(10,45,mBitmapFont,getString(R.string.question1),getVertexBufferObjectManager());
您可以缩放文本

if (question.getWidth() > CAMERA_WIDTH) {
    question.setScale(1/(question.getWidth()/CAMERA_WIDTH));
}

或者换行符文本中的“\n”。

@Alexey谢谢我解决了这个问题;当我使用你的解决方案时,你的解决方案起作用了

    question = new Text(0, 0, mBitmapFont, getString(R.string.question10),
            getVertexBufferObjectManager());
   question.setScale(1/(question.getWidth()/CAMERA_WIDTH));
  question.setPosition((CAMERA_WIDTH - question.getWidth()) * 0.5f,5);

现在文本在相机边界内。

它不工作,只缩放文本bt文本超出相机宽度您的安引擎版本是什么?我在GLES2-AE上的示例工作和文本x位置是屏幕的中心。当您使用AndEnigne时,您必须在应用程序或游戏中只关注一个方向。