android - Loading AutoParallaxBackground Andengine Texture -
i'm rookie in andengine . working simple andengine game project , want load parallax background . follow step nicolas gramlich shows in parallax background example . got problem after running code saw black screen blinking colors
i think problem buildabletextureatlas , parallaxtexture here code resourcemanager class
public itiledtextureregion playertiledtextureregion; public itiledtextureregion enemytiledtextureregion; public itextureregion platformtextureregion; public itextureregion cloudonetextureregion; public itextureregion cloudtwotextureregion; public itextureregion cloudthreetextureregion; private buildablebitmaptextureatlas gametextureatlas; public bitmaptextureatlas mautoparallaxbackgroundtexture; public itextureregion mparallaxlayerback; public itextureregion mparallaxlayermid; public itextureregion mparallaxlayerfront; //sounds sound soundfall; sound soundjump; //music music music; //font font scorefont;
here loadresource() method
public void loadresources(){ bitmaptextureatlastextureregionfactory.setassetbasepath("gfx/"); gametextureatlas = new buildablebitmaptextureatlas(mgameactivity.gettexturemanager(), 1024, 512,bitmaptextureformat.rgba_8888,textureoptions.nearest_premultiplyalpha); playertiledtextureregion = bitmaptextureatlastextureregionfactory.createtiledfromasset(gametextureatlas,mgameactivity.getassets(), "player.png", 3, 1); enemytiledtextureregion = bitmaptextureatlastextureregionfactory.createtiledfromasset(gametextureatlas, mgameactivity.getassets(), "enemy.png", 1, 2); cloudonetextureregion = bitmaptextureatlastextureregionfactory.createfromasset(gametextureatlas, mgameactivity.getassets(), "cloud1.png"); cloudtwotextureregion = bitmaptextureatlastextureregionfactory.createfromasset(gametextureatlas, mgameactivity.getassets(), "cloud2.png"); platformtextureregion = bitmaptextureatlastextureregionfactory.createfromasset(gametextureatlas, mgameactivity.getassets(), "platform.png"); mautoparallaxbackgroundtexture = new bitmaptextureatlas(mgameactivity.gettexturemanager(), 1024, 512); mparallaxlayerfront = bitmaptextureatlastextureregionfactory.createfromasset(mautoparallaxbackgroundtexture, mgameactivity, "parallax_background_layer_front.png", 0, 0); mparallaxlayerback = bitmaptextureatlastextureregionfactory.createfromasset(mautoparallaxbackgroundtexture, mgameactivity, "parallax_background_layer_back.png", 0, 188); mparallaxlayermid = bitmaptextureatlastextureregionfactory.createfromasset(mautoparallaxbackgroundtexture, mgameactivity, "parallax_background_layer_mid.png", 0, 669); try{ gametextureatlas.build(new blackpawntextureatlasbuilder<ibitmaptextureatlassource, bitmaptextureatlas>(2, 0, 2)); /*gametextureatlas.load();*/ mautoparallaxbackgroundtexture.load(); }catch(final textureatlasbuilderexception e){ e.printstacktrace(); throw new runtimeexception("error while loading textures", e); } }
now gamescene class
scene scene = new scene(); autoparallaxbackground autoparallaxbackground = new autoparallaxbackground(0, 0, 0, 5); autoparallaxbackground.attachparallaxentity(new parallaxentity(0.0f, new sprite(0, 200, resmanager.mparallaxlayerback, resmanager.vbom))); autoparallaxbackground.attachparallaxentity(new parallaxentity(-5.0f, new sprite(0, 80, resmanager.mparallaxlayermid, resmanager.vbom))); autoparallaxbackground.attachparallaxentity(new parallaxentity(-10.0f, new sprite(0, 400, resmanager.mparallaxlayerfront, resmanager.vbom))); /*sprite cloud1 = new sprite(200,300, resmanager.cloudonetextureregion, resmanager.vbom); sprite cloud2 = new sprite(300,600, resmanager.cloudtwotextureregion, resmanager.vbom);*/ scene.setbackground(autoparallaxbackground);
tried create autoparallaxbackground , set current scene object got black , hazy blinking screen after running code. please me out here. spend whole night after solving problem.
Comments
Post a Comment