particles disappear when it showed for second time

I have 2 pages ,In first page when I click one of the item in listview,it should navigate to 2nd page and here in 2nd page snow particles are appeared.After that when I click back button,As usual it goes to first page and again when I click any of the listview items ,when it navigates to 2nd page ,snow particles disappear,It just show a black screen.
Here are my codes-
For snow rendering I have two classes-
First one-
public class SnowScene : CCScene
{
CCParticleSnow snow;

public SnowScene(CCGameView gameView) : base(gameView)
{
    var layer = new CCLayer();
    layer.Color=new CCColor3B(new CCColor4B(20,30,50,10));


    snow = new CCParticleSnow(new CCPoint(490, 20));
    snow.Position = new CCPoint(490 / 2, 800 + 1);
    snow.StartColor = new CCColor4F(CCColor4B.White);
    snow.EndColor = new CCColor4F(CCColor4B.Red);
    snow.StartSize = 15f;
    snow.StartSizeVar = 2f;
    snow.EndSize = 8f;
    snow.EndSizeVar = 1f;
    snow.Speed = 5f;
    snow.Gravity = new CCPoint(0.5f, -2);
    snow.EmissionRate = 3.5f;
    snow.Life = 50f;


    layer.AddChild(snow);
    this.AddLayer(layer);

}

}
Second one-
public class SnowyBackground : ContentView
{
SnowScene overallScene;

public SnowyBackground()

{
var sharpView = new CocosSharpView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};

sharpView.ViewCreated += (sender, e) =>
{
    var ccGView = sender as CCGameView;

    if (ccGView != null)
    {
        ccGView.DesignResolution = new CCSizeI(490, 800);


        overallScene = new SnowScene(ccGView);

        ccGView.RunWithScene(overallScene);
        }
    };

    Content = sharpView;
}

}
}
And in Xaml in Second page-
Now When I click an Item of listview in first page(page1) like below-
async void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
{
try
{

        await Navigation.PushModalAsync(new Page2(),false);
    }
    catch(Exception ex)
    {

    }

}

It navigates to page 2 and it successfully shows snow rendering.But when I repeat same steps....I mean If I click back button in page 2,then it goes to page1 and here when again I click lictview item,it goes to second page,but it doesnot show snow rendering,just a black screen.

Sign In or Register to comment.