我正在使用Libgdx,当我尝试进入另一个屏幕时,我在logcat中遇到了这个错误:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x6a581000 in tid 7616 (GLThread 7982)
这只发生在设备上而不是桌面模拟器上。
屏幕我试图设置:
public class PlayScreen implements Screen {
private static RunningGame game;
private TextureAtlas atlas;
private OrthographicCamera gamecam;
private Viewport gamePort;
private Hud hud;
private TmxMapLoader maploader;
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;
private World world;
private Box2DDebugRenderer b2dr;
private Runner player;
private float dt;
private boolean keyPressed = false;
public PlayScreen(RunningGame game){
atlas = new TextureAtlas("Runner_And_Enemies.pack");
this.game = game;
gamecam = new OrthographicCamera();
gamePort = new FitViewport(RunningGame.V_WIDTH / RunningGame.PPM, RunningGame.V_HEIGHT / RunningGame.PPM, gamecam);
hud = new Hud(game.batch);
maploader = new TmxMapLoader();
map = maploader.load("level1.tmx");
renderer = new OrthogonalTiledMapRenderer(map, 1 / RunningGame.PPM);
gamecam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2 ,0);
world = new World(new Vector2(0, -10), true);
b2dr = new Box2DDebugRenderer();
new B2WorldCreator(world, map);
player = new Runner(world, this);
}
public TextureAtlas getAtlas(){
return atlas;
}
@Override
public void show() {
}
public void handleInput(float dt){
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
if (!keyPressed) {
keyPressed = true;
if (player.b2body.getLinearVelocity().x <= 4) {
player.b2body.applyLinearImpulse(new Vector2(0.3f, 0), player.b2body.getWorldCenter(), true);
}
Hud.addscore(1);
}
} else {
keyPressed = false;
}
if (Gdx.input.isKeyPressed(Input.Keys.UP))
player.b2body.applyLinearImpulse(new Vector2(0, 0.4f), player.b2body.getWorldCenter(), true);
if (Gdx.input.isKeyPressed(Input.Keys.LEFT) && player.b2body.getLinearVelocity().x >= -2)
player.b2body.applyLinearImpulse(new Vector2(-5.2f, 0), player.b2body.getWorldCenter(), true);
}
public void update(float dt){
handleInput(dt);
world.step(1 / 60f, 6, 2);
player.update(dt);
gamecam.position.x = player.b2body.getPosition().x;
gamecam.update();
renderer.setView(gamecam);
}
@Override
public void render(float delta) {
update(delta);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.render();
b2dr.render(world, gamecam.combined);
game.batch.setProjectionMatrix(gamecam.combined);
game.batch.begin();
player.draw(game.batch);
game.batch.end();
game.batch.setProjectionMatrix(hud.stage.getCamera().combined);
hud.stage.draw();
}
@Override
public void resize(int width, int height) {
gamePort.update(width, height);
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void hide() {
}
@Override
public void dispose() {
map.dispose();
renderer.dispose();
world.dispose();
b2dr.dispose();
hud.dispose();
}
}
我如何设置PlayScreen:
@Override
public void clicked(InputEvent event, float x, float y) {
stage.addAction(sequence(moveTo(0, -stage.getHeight(), .5f), run(new Runnable() {
@Override
public void run() {
((Game) Gdx.app.getApplicationListener()).setScreen(new PlayScreen(game));
}
})));
}
logcat的:
02-24 10:10:20.008 12792-12792/? E/Zygote: MountEmulatedStorage()
02-24 10:10:20.008 12792-12792/? E/Zygote: v2
02-24 10:10:20.008 12792-12792/? I/libpersona: KNOX_SDCARD checking this for 10233
02-24 10:10:20.008 12792-12792/? I/libpersona: KNOX_SDCARD not a persona
02-24 10:10:20.008 12792-12792/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-G925F_5.1.1_0041
02-24 10:10:20.008 12792-12792/? E/Zygote: accessInfo : 0
02-24 10:10:20.008 12792-12792/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
02-24 10:10:20.008 12792-12792/? I/art: Late-enabling -Xcheck:jni
02-24 10:10:20.038 12792-12792/? D/TimaKeyStoreProvider: TimaSignature is unavailable
02-24 10:10:20.038 12792-12792/? D/ActivityThread: Added TimaKeyStore provider
02-24 10:10:20.038 12792-12799/? E/art: Failed sending reply to debugger: Broken pipe
02-24 10:10:20.038 12792-12799/? I/art: Debugger is no longer active
02-24 10:10:20.218 12792-12792/? I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
02-24 10:10:20.218 12792-12792/? I/InjectionManager: Inside getClassLibPath caller
02-24 10:10:20.228 12792-12792/? D/InjectionManager: InjectionManager
02-24 10:10:20.228 12792-12792/? D/InjectionManager: fillFeatureStoreMap com.mygdx.game
02-24 10:10:20.238 12792-12792/? I/InjectionManager: Constructor com.mygdx.game, Feature store :{}
02-24 10:10:20.238 12792-12792/? I/InjectionManager: featureStore :{}
02-24 10:10:20.278 12792-12792/? D/SecWifiDisplayUtil: Metadata value : SecSettings2
02-24 10:10:20.318 12792-12792/? D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
02-24 10:10:20.418 12792-12792/? D/PhoneWindow: *FMB* installDecor mIsFloating : false
02-24 10:10:20.418 12792-12792/? D/PhoneWindow: *FMB* installDecor flags : 8455424
02-24 10:10:20.418 12792-12792/? D/Activity: performCreate Call Injection manager
02-24 10:10:20.438 12792-12792/? I/InjectionManager: dispatchOnViewCreated > Target : com.mygdx.game.AndroidLauncher isFragment :false
02-24 10:10:20.478 12792-12792/? D/SensorManager: registerListener :: 0, MPU6500 Acceleration Sensor, 20000, 0,
02-24 10:10:20.478 12792-12792/? D/SensorManager: registerListener :: 1, YAS537 Magnetic Sensor, 20000, 0,
02-24 10:10:20.478 12792-12792/? I/AndroidInput: sensor listener setup
02-24 10:10:20.498 12792-12916/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-24 10:10:20.508 12792-12792/? D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
02-24 10:10:20.508 12792-12792/? D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
02-24 10:10:20.528 12792-12792/? D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered!
02-24 10:10:20.528 12792-12916/? I/OpenGLRenderer: Initialized EGL, version 1.4
02-24 10:10:20.538 12792-12916/? I/OpenGLRenderer: HWUI protection enabled for context , &this =0x7f81633440 ,&mEglDisplay = 1 , &mEglConfig = -2122624336
02-24 10:10:20.538 12792-12916/? D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
02-24 10:10:20.538 12792-12916/? D/OpenGLRenderer: Enabling debug mode 0
02-24 10:10:20.538 12792-12916/? D/mali_winsys: new_window_surface returns 0x3000, [2560x1440]-format:1
02-24 10:10:20.568 12792-12881/? W/GL2JNIView: creating OpenGL ES 2.0 context
02-24 10:10:20.568 12792-12881/? W/GL2JNIView: Returning a GLES 2 context
02-24 10:10:20.568 12792-12881/? D/mali_winsys: new_window_surface returns 0x3000, [2560x1440]-format:4
02-24 10:10:20.578 12792-12881/? I/GL2: all initialized 2
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: OGL renderer: Mali-T760
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: OGL vendor: ARM
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: OGL version: OpenGL ES 3.1
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: OGL extensions: GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_KHR_blend_equation_advanced GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic GL_EXT_robustness
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: framebuffer: (5, 6, 5, 0)
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: depthbuffer: (24)
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: stencilbuffer: (0)
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: samples: (0)
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: coverage sampling: (false)
02-24 10:10:20.578 12792-12881/? I/AndroidGraphics: Managed meshes/app: { }
02-24 10:10:20.588 12792-12881/? I/AndroidGraphics: Managed textures/app: { }
02-24 10:10:20.588 12792-12881/? I/AndroidGraphics: Managed cubemap/app: { }
02-24 10:10:20.588 12792-12881/? I/AndroidGraphics: Managed shaders/app: { }
02-24 10:10:20.588 12792-12881/? I/AndroidGraphics: Managed buffers/app: { }
02-24 10:10:20.718 12792-12792/? I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1acaec3d time:207840769
02-24 10:10:20.828 12792-12792/? D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
02-24 10:10:23.168 12792-12792/com.mygdx.game D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
02-24 10:10:29.668 12792-12792/com.mygdx.game D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
02-24 10:10:30.558 12792-12881/com.mygdx.game A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x6a493000 in tid 12881 (GLThread 8342)