Пример #1
0
        public override void Start()
        {
            var virtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height, 20f);

            // Create Parallax Background
            pal0SpriteSheet = Asset.Load<SpriteSheet>("pal0_sprite");
            pal1SpriteSheet = Asset.Load<SpriteSheet>("pal1_sprite");
            pal2SpriteSheet = Asset.Load<SpriteSheet>("pal2_sprite");
            backgroundParallax.Add(new BackgroundSection(pal0SpriteSheet.Sprites[0], virtualResolution, GameScript.GameSpeed / 4f, Pal0Depth));
            backgroundParallax.Add(new BackgroundSection(pal1SpriteSheet.Sprites[0], virtualResolution, GameScript.GameSpeed / 3f, Pal1Depth));
            backgroundParallax.Add(new BackgroundSection(pal2SpriteSheet.Sprites[0], virtualResolution, GameScript.GameSpeed / 1.5f, Pal2Depth));

            // For pal3Sprite: Ground, move it downward so that its bottom edge is at the bottom screen.
            var screenHeight = virtualResolution.Y;
            pal3SpriteSheet = Asset.Load<SpriteSheet>("pal3_sprite");
            var pal3Height = pal3SpriteSheet.Sprites[0].Region.Height;
            backgroundParallax.Add(new BackgroundSection(pal3SpriteSheet.Sprites[0], virtualResolution, GameScript.GameSpeed, Pal3Depth, Vector2.UnitY * (screenHeight - pal3Height) / 2));

            // allocate the sprite batch in charge of drawing the backgrounds.
            spriteBatch = new SpriteBatch(GraphicsDevice) { VirtualResolution = virtualResolution };

            // register the renderer in the pipeline
            var scene = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);
            compositor.Master.Renderers.Insert(1, delegateRenderer = new SceneDelegateRenderer(DrawParallax));
        }
Пример #2
0
        public override void Start()
        {
            // create the ball sprite.
            var virtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height, 1);
            spriteBatch = new SpriteBatch(GraphicsDevice) { VirtualResolution = virtualResolution };
            sphere = Asset.Load<Texture>("sphere");

            // Initialize ball's state related variables.
            resolution = new Vector2(virtualResolution.X, virtualResolution.Y);
            ballHalfSize = new Vector2(SphereWidth / 2, SphereHeight / 2);
            ballPosition = resolution / 2;
            ballSpeed = new Vector2(600, -400);

            // Add Graphics Layer
            var scene = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);
            compositor.Master.Renderers.Add(delegateRenderer = new SceneDelegateRenderer(RenderSpheres));
        }
Пример #3
0
        public override void Start()
        {
            base.Start();

            paradoxTexture = Asset.Load<Texture>("LogoParadox");
            customEffect = EffectSystem.LoadEffect("Effect").WaitForResult();
            quad = new PrimitiveQuad(GraphicsDevice, customEffect);

            // set fixed parameters once
            quad.Parameters.Set(EffectKeys.Center, new Vector2(0.5f, 0.5f));
            quad.Parameters.Set(EffectKeys.Frequency, 40);
            quad.Parameters.Set(EffectKeys.Spread, 0.5f);
            quad.Parameters.Set(EffectKeys.Amplitude, 0.015f);
            quad.Parameters.Set(EffectKeys.InvAspectRatio, GraphicsDevice.BackBuffer.Height / (float)GraphicsDevice.BackBuffer.Width);

            // NOTE: Linear-Wrap sampling is not available for non-square non-power-of-two textures on opengl es 2.0
            samplingState = SamplerState.New(GraphicsDevice, new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Clamp));

            // Add Effect rendering to the end of the pipeline
            var scene = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);
            renderer = new SceneDelegateRenderer(RenderQuad);
            compositor.Master.Renderers.Add(renderer);
        }
Пример #4
0
        /// <summary>
        /// Draw all text groups with SpriteBatch
        /// </summary>
        public override void Start()
        {
            // Create the SpriteBatch used to render them
            spriteBatch = new SpriteBatch(GraphicsDevice) { VirtualResolution = new Vector3(virtualResolution, 1000) };

            centerVirtualPosition = new Vector2(virtualResolution.X * 0.5f, virtualResolution.Y * 0.5f);
            screenSize = new Vector2(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height);

            // Load fonts
            staticFont = Asset.Load<SpriteFont>("StaticFont");
            dynamicFont = Asset.Load<SpriteFont>("DynamicFont");
            boldFont = Asset.Load<SpriteFont>("BoldFont");
            italicFont = Asset.Load<SpriteFont>("ItalicFont");

            aliasedFont = Asset.Load<SpriteFont>("AliasedFont");
            antialiasedFont = Asset.Load<SpriteFont>("AntialiasedFont");
            clearTypeFont = Asset.Load<SpriteFont>("ClearTypeFont");

            japaneseFont = Asset.Load<SpriteFont>("JapaneseFont");
            timesNewRoman = Asset.Load<SpriteFont>("TimesNewRoman");
            headerFont = Asset.Load<SpriteFont>("HeaderFont");

            screenRenderers.Add(DrawIntroductionCategory);
            screenRenderers.Add(DrawStaticCategory);
            screenRenderers.Add(DrawDynamicCategory);
            screenRenderers.Add(DrawStyleCategory);
            screenRenderers.Add(DrawAliasCategory);
            screenRenderers.Add(DrawLanguageCategory);
            screenRenderers.Add(DrawAlignmentCategory);
            screenRenderers.Add(DrawAnimationCategory);

            // Add Graphics Layer
            var scene = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers) scene.Settings.GraphicsCompositor);
            compositor.Master.Renderers.Add(delegateRenderer = new SceneDelegateRenderer(DrawFont));
        }