Xamarin forms with CocosSharp - Cache async

Junior_OliveiraJunior_Oliveira USMember ✭✭

Hi!,

I'm using cocosharp, but I can not load the cache asynchronously.

My Code:

public SimulatorPage()
        {
            // We'll be adding our CocosSharpView here:
            this.VerticalOptions = LayoutOptions.FillAndExpand;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;

            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            this.Children.Add(gameView, 0, 0);

        }

        private void HandleViewCreated(object sender, EventArgs e)
        {
            var gameView = sender as CCGameView;

            if (gameView != null)
            {
                gameView.DesignResolution = new CCSizeI(App.SceneWidth, App.SceneHeight);
                gameView.ResolutionPolicy = CCViewResolutionPolicy.FixedWidth;
                gameView.ContentManager.SearchPaths = new List<string>() { "Fonts", "Sounds", "Images", "Images/Electrical", "Images/Pneumatic", "SpriteSheets" };

                //PreLoad Images in Cache
                PreLoadImages();

                // GameScene is the root of the CocosSharp rendering hierarchy:
                gameScene = new GameScene(this, gameView);

                // Starts CocosSharp:
                gameView.RunWithScene(gameScene);
            }
        }

        private void PreLoadImages()
        {
            var cache = CCTextureCache.SharedTextureCache;

            cache.AddImage("Image1");
            cache.AddImage("Image2");
            cache.AddImage("Image3");

       }

I want to use cache.AddImageAsync, Can you help me please?

Sign In or Register to comment.