A collection of images.
상속: Component, IDisposable
예제 #1
0
        public BackgroundKite(float initialX)
        {
            var scale = this.GetRandomScale();

            var scrollBehavior = new ScrollBehavior(scale * 0.1f);

            var transform = new Transform2D()
            {
                X = initialX,
                Y = WaveServices.ViewportManager.VirtualHeight,
                Origin = Vector2.UnitY,
                XScale = scale,
                YScale = scale
            };

            var spriteAtlas = new SpriteAtlas(Textures.GAME_ATLAS, this.GetRandomTextureName());

            this.entity = new Entity()
                .AddComponent(transform)
                .AddComponent(spriteAtlas)
                .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque))
                .AddComponent(scrollBehavior);

            scrollBehavior.EntityOutOfScreen += (entity) =>
            {
                transform.X = WaveServices.ViewportManager.RightEdge;

                var newScale = this.GetRandomScale();
                transform.XScale = newScale;
                transform.YScale = newScale;

                //Set a new kite texture
                spriteAtlas.TextureName = this.GetRandomTextureName();
            };
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteAtlasRenderer" /> class.
 /// </summary>
 /// <param name="layerType">Type of the layer.</param>
 /// <param name="samplerMode">The sampler mode.</param>
 public SpriteAtlasRenderer(Type layerType, AddressMode samplerMode = AddressMode.LinearClamp)
     : base("SpriteAtlasRenderer" + instances++, layerType)
 {
     this.Transform2D = null;
     this.Sprite = null;
     this.origin = Vector2.Zero;
     this.samplerMode = samplerMode;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteAtlasRenderer" /> class.
 /// </summary>
 /// <param name="layerType">Type of the layer.</param>
 public SpriteAtlasRenderer(Type layerType)
     : base("SpriteAtlasRenderer" + instances++, layerType)
 {
     this.Transform2D = null;
     this.Sprite = null;
     this.scale = Vector2.Zero;
     this.position = Vector2.Zero;
     this.origin = Vector2.Zero;
 }