android - Black screen on running the code -
i'm trying understand sprites in andengine. wrote below code load simple image "img"
package com.example.pxc; import org.andengine.engine.camera.camera; import org.andengine.engine.options.engineoptions; import org.andengine.engine.options.screenorientation; import org.andengine.engine.options.resolutionpolicy.ratioresolutionpolicy; import org.andengine.entity.scene.scene; import org.andengine.entity.sprite.sprite; import org.andengine.opengl.texture.atlas.bitmap.bitmaptextureatlas; import org.andengine.opengl.texture.atlas.bitmap.bitmaptextureatlastextureregionfactory; import org.andengine.opengl.texture.atlas.bitmap.buildablebitmaptextureatlas; import org.andengine.opengl.texture.atlas.bitmap.source.ibitmaptextureatlassource; import org.andengine.opengl.texture.atlas.buildable.builder.blackpawntextureatlasbuilder; import org.andengine.opengl.texture.atlas.buildable.builder.itextureatlasbuilder.textureatlasbuilderexception; import org.andengine.opengl.texture.region.itextureregion; import org.andengine.ui.activity.simplebasegameactivity; public class testactivity extends simplebasegameactivity { static final int camera_width = 800; static final int camera_height = 480; buildablebitmaptextureatlas bbta; itextureregion msr; @override public engineoptions oncreateengineoptions() { camera mcamera = new camera(0, 0, camera_width, camera_height); return new engineoptions(true, screenorientation.landscape_fixed, new ratioresolutionpolicy(camera_width, camera_height), mcamera); } @override protected void oncreateresources() { // todo auto-generated method stub bitmaptextureatlastextureregionfactory.setassetbasepath("gfx/"); bbta = new buildablebitmaptextureatlas(mengine.gettexturemanager(), 256, 256); msr=bitmaptextureatlastextureregionfactory.createfromasset(bbta, this, "img.png"); try{ bbta.build(new blackpawntextureatlasbuilder<ibitmaptextureatlassource, bitmaptextureatlas>(0, 1, 1)); bbta.load(); } catch (textureatlasbuilderexception e) { e.printstacktrace(); } } @override protected scene oncreatescene() { scene scene = new scene(); sprite msprite = new sprite(0, 0, msr, mengine.getvertexbufferobjectmanager()); scene.attachchild(msprite); return scene; } }
the above code compiles without errors. when run code, see black screen on emulator instead of image. why happens? , how can resolve problem?
if want run on emulator first have provide settings shown in this link if want effective 1 fps following link may you
Comments
Post a Comment