Hello,
I'm trying to set one of my sprites to be always on top, and it is, althrought if I hide sprites from one scene and show from next one, it shows behind other sprites.
there's effect, which I want to make:
void makeScreenVisible( bool yes )
{
if( yes == true )
{
ef1_alpha = 254;
//dbShowSprite( id_effect1 );
dbSetSpriteAlpha( id_effect1 , ef1_alpha );
while( LoopGDK ( ) )
{
dbSetSpriteAlpha( id_effect1 , ef1_alpha );
dbSprite( id_effect1 , 0 , 0 , id_effect1 );
ef1_alpha -=2;
if( ef1_alpha == 0 )
{
ef1_alpha = 255;
break;
}
if ( dbEscapeKey ( ) )
break;
dbSync();
}
ef1_alpha = 254;
//dbHideSprite( id_effect1 );
}
if ( yes == false )
{
ef1_alpha = 0;
//dbShowSprite( id_effect1 );
dbSetSpriteAlpha( id_effect1 , ef1_alpha );
while( LoopGDK ( ) )
{
dbSetSpriteAlpha( id_effect1 , ef1_alpha );
dbSprite( id_effect1 , 0 , 0 , id_effect1 );
ef1_alpha +=2;
if( ef1_alpha == 254 )
{
ef1_alpha = 0;
break;
}
if ( dbEscapeKey ( ) )
break;
dbSync();
}
ef1_alpha = 0;
//dbHideSprite( id_effect1 );
}
}
Setting priority:
dbSetSpritePriority ( 1, 1 ) ;
dbSetSpritePriority ( 2, 1 ) ;
dbSetSpritePriority ( id_effect1, 2 ) ;
And I use it, first time when scene loades, and second when I'm exiting scene.
if( dbMouseClick() == 2 )//exiting scene
{
GAME_TYPE = SHOP;
dbHideSprite( id_bg1 );
dbHideSprite( id_player );
dbHideSprite( id_bullet );
makeScreenVisible( false );
break;
}
if ( dbEscapeKey ( ) )
break;
dbSync ( );
if( effect1_buf2 == 1 )//first loop entry
{
makeScreenVisible( true );
effect1_buf2 = 0;
}
}
}