Просмотр исходного кода

proper slider marker position calculation (no jumping on touch)

Andrew Karpushin 11 лет назад
Родитель
Сommit
020573a73d
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      gameplay/src/Slider.cpp

+ 1 - 1
gameplay/src/Slider.cpp

@@ -169,7 +169,7 @@ void Slider::updateValue(int x, int y)
     const Rectangle& maxCapRegion = _maxImage->getRegion();
     const Rectangle& markerRegion = _markerImage->getRegion();
 
-    float markerPosition = x / (_viewportBounds.width - markerRegion.width);
+    float markerPosition = (x - markerRegion.width * 0.5f) / (_viewportBounds.width - markerRegion.width);
             
     if (markerPosition > 1.0f)
     {