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(); }; }
/// <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; }
/// <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; }