Esempio n. 1
0
        void IHandler <Start> .Handle(FrameArgs frame, Start e)
        {
            _cam = new Camera2D(e.Size, 1000f, Camera2DOrigin.LowerLeft);

            // create our UI root. adding it to the scene allows events
            // like touch and resize to filter through the UI hierarchy.
            // it also automatically disposes the hierarchy.
            _root = new RootView(e.Size, 0f);
            this.Add(_root);

            // create our custom progress bar to stretch across most
            // of the screen
            _bar = new ProgressBarView(new LayoutSpec {
                Top    = p => (e.Size.Y - 30f) / 2f,
                Height = p => 30f,
                Left   = p => 50,
                Right  = p => 50
            });
            _root.AddView(_bar);

            // spin up a coroutine to animate the progress bar
            // keeping a reference to the coroutine list allows us to
            // access frame args from within coroutines
            _co = new CoroutineList <FrameArgs>();
            this.Add(_co);
            _co.Start(this.CoAnimateBar());
        }
Esempio n. 2
0
        void IHandler <Start> .Handle(FrameArgs frame, Start e)
        {
            var musicChannel = new StreamingSoundChannel();
            var music        = new StreamingOpusFile("mario.opus");
            var co           = new CoroutineList <FrameArgs>();

            // make sure this all gets disposed/tracked
            this.AddMany(musicChannel, music, co);

            // start the music
            musicChannel.PlaySound(music);

            // loop will handle the sound effect
            co.Start(this.CoPlayRepeat());
        }
Esempio n. 3
0
        void IHandler <Start> .Handle(FrameArgs frame, Start e)
        {
            _cam = new Camera2D(e.Size, 1000f, Camera2DOrigin.Center);

            // we'll use a solid red material
            _mat = new SpriteMaterial(new SolidColorShader(), null)
            {
                Color = new Vector4(1, 0, 0, 1)
            };

            // create a quad with an origin at the center and unit size
            _quad = new Quad(_mat, new Vector4(-0.5f, -0.5f, 0.5f, 0.5f),
                             Vector4.One);

            _pos = new Vector3(-200, 0, 0);

            // fire up the coroutine
            var co = new CoroutineList <FrameArgs>();

            this.Add(co);
            co.Start(this.CoAnimate());
        }