Exemple #1
0
        public Slider(
            float minValue,
            float maxValue,
            float currentValue,
            string infoText,
            Vector2 localPosition,
            string sliderHandleTextureAsset = AssetManager.DefaultSliderHandleTextureAsset,
            string sliderBarTextureAsset = AssetManager.DefaultSliderBarTextureAsset,
            float lifeTime = float.MaxValue) :
            base(localPosition, sliderBarTextureAsset, lifeTime)
        {
            // We do not want to use collisions ourself, but rather for our handle
            UsesCollider = false;

            // Our bar will not have any collision detection on it
            SliderHandle = new Image(Vector2.Zero, sliderHandleTextureAsset, lifeTime);
            SliderHandle.SetParent(this);

            // Fix up our label position after all the textures are initialised
            // Parent it to the bar
            InfoLabel = new Label(infoText, Vector2.Zero, AssetManager.DefaultSpriteFontAsset, lifeTime);
            InfoLabel.SetParent(this);

            // Fix up our label position after all the textures are initialised
            // Parent it to the bar
            ValueLabel = new Label(currentValue.ToString(), Vector2.Zero);
            ValueLabel.SetParent(this);

            MaxValue = maxValue;
            MinValue = minValue;
            CurrentValue = new Property<float>(currentValue);
        }