以下代码展示了我如何将一个Libgdx游戏(MyGdxGame)加载到LinearLayout中。在游戏创建时,我设置了一个相机并加载了一个小的wav音频文件。纹理在视图加载后加载。
问题是在片段转换到此片段期间,会出现明显的黑色闪烁和延迟。是否有可能减少这种情况并改善片段转换。
问题是在片段转换到此片段期间,会出现明显的黑色闪烁和延迟。是否有可能减少这种情况并改善片段转换。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = null;
Bundle bundle = getArguments();
if (bundle != null) {
this.input = bundle.getParcelable(Utils.FRAGMENT_INPUT_KEY);
} else {
input = new FragmentInput();
}
view = inflater.inflate(R.layout.solve, container, false);
surface = (LinearLayout) view.findViewById(R.id.puzzleView);
activity = (MainActivity) getActivity();
com.badlogic.gdx.graphics.Color color = new com.badlogic.gdx.graphics.Color(Color.red(input.backColor) / 255f,
Color.green(input.backColor) / 255f,
Color.blue(input.backColor) / 255f, 1.0f);
size = input.pieceCount;
cols = input.columns;
GameData gdata = new GameData();
gdata.rows = size / cols;
gdata.columns = cols;
gdata.backColor = color;
gdata.setCategory(input.category);
if (input.rotated) {
gameView = new MyGdxGameRotate(this, gdata);
} else {
gameView = new MyGdxGame(this, gdata);
}
if (surface != null) {
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
View game = initializeForView(gameView, config);
surface.addView(game);
}
return view;
}