Exemple #1
0
        public static void LoadSharedAssetsOnce()
        {
                        #if __IOS__
            var whiteColor = UIColor.White;
                        #else
            NSColor whiteColor = null;
            new NSObject().InvokeOnMainThread(() => {
                whiteColor = NSColor.White;
            });
                        #endif

            SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment");

            SKEmitterNode fire = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFire");
            fire.ZPosition = 1;

            SKEmitterNode smoke = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFireSmoke");

            var sKNode = new SKNode();
            sKNode.Add(fire);
            sKNode.Add(smoke);
            SKNode torch = sKNode;

            sharedCaveBase = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_base.png"));

            // Add two torches either side of the entrance.
            torch.Position = new CGPoint(83, 83);
            sharedCaveBase.AddChild(torch);
            var torchB = (SKNode)torch.Copy();
            torchB.Position = new CGPoint(-83, 83);
            sharedCaveBase.AddChild(torchB);

            sharedCaveTop     = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_top.png"));
            sharedDeathSplort = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_destroyed.png"));

            sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDamage");
            sharedDeathEmitter  = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDeathSmoke");

            sharedDamageAction = SKAction.Sequence(new [] {
                SKAction.ColorizeWithColor(whiteColor, 1, 0),
                SKAction.WaitForDuration(0.25),
                SKAction.ColorizeWithColorBlendFactor(0, 0.1),
            });
        }