android - Why does ScaleModifier make sprite flicker? -


i'm playing around in andengine , learning non-documented while making splashscreen. i'm aware there's class splashscene, i'm learning i'm trying kind of ways.

however, can't seem 1 right. screen 240x320 (w x h) , splash screen texture 480x640 i'm scaling down fit screen. texture loading etc working fine, when sprite shown first see large texture 0.1secs, gets scaled down. want scaled down prior shown. been trying everything, moved call attachchild() onloadcomplete(), using setvisible(false), etc see texture getting scaled down everytime.

why?

here's code:

@override public scene onloadscene() {   this.scene = new scene();    // texture sizes   final int sx = msplashtextureregion.getwidth();   final int sy = msplashtextureregion.getheight();    // center on camera   final int cx = (camera_width - sx) / 2;   final int cy = (camera_height - sy) / 2;    // scale factor according camera   final float scalefactor = math.min((float) camera_width / sx, (float) camera_height / sy);    // init sprite   splashscreen = new sprite(cx, cy, msplashtextureregion);   splashscreen.setvisible(false);    // rescale splash-screen fit display, move (0, 0) , show it.   splashscreen.registerentitymodifier(new scalemodifier(0.1f, 1.0f, scalefactor));    //splashscreen.registerentitymodifier(new scaleatmodifier(0.001f, 1.0f, scalefactor, 0, 0));   // splashscreen.registerentitymodifier(new sequenceentitymodifier(   // new scalemodifier(0.1f, 1.0f, scalefactor),   // new delaymodifier(0.2f)   // ));    return scene; }  @override public void onloadcomplete() {   scene.attachchild(splashscreen);   splashscreen.setvisible(true); } 

if rewrite onloadcomplete() in this:

@override public void onloadcomplete() {   scene.attachchild(splashscreen);    mhandler.postdelayed(korv, 1000); }  private runnable korv = new runnable() {   @override   public void run() {     splashscreen.setvisible(true);    } }; 

the flicker gone, doesn't feel solution.

scalemodifier adjust scale on specified time factor - in case 0.1f

scalemodifier(0.1f, 1.0f, scalefactor) 

what want scale sprite directly using

splashscreen.setscale(scalefactor); 

do before attaching child , should fine.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -