瀏覽代碼

Fixes bug where Joystick control was not being dirtied.
Fixes bug where the clear bounds of the Joystick control was incorrectly set, leaving artifacts behind when being moved around. It wasn't taking into account the area that the inner joggle can rotate around the outer dock.

Kieran Cunney 13 年之前
父節點
當前提交
55391510b9
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 5 1
      gameplay/src/Control.h
  2. 10 0
      gameplay/src/Joystick.cpp

+ 5 - 1
gameplay/src/Control.h

@@ -872,6 +872,11 @@ protected:
      */
     Rectangle _viewportClipBounds;
 
+    /**
+     * Previous frame's absolute clip bounds, to be cleared if necessary.
+     */
+    Rectangle _clearBounds;         
+
     /**
      * If the control is dirty and need updating.
      */
@@ -952,7 +957,6 @@ private:
     
     bool _styleOverridden;
     Theme::Skin* _skin;
-    Rectangle _clearBounds;         // Previous frame's absolute clip bounds, to be cleared if necessary.
 };
 
 }

+ 10 - 0
gameplay/src/Joystick.cpp

@@ -94,6 +94,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 if (_value != value)
                 {
                     _value.set(value);
+                    _dirty = true;
                     notifyListeners(Control::Listener::VALUE_CHANGED);
                 }
 
@@ -114,6 +115,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                     if (_value != value)
                     {
                         _value.set(value);
+                        _dirty = true;
                         notifyListeners(Control::Listener::VALUE_CHANGED);
                     }
                 }
@@ -126,6 +128,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                     if (_value != value)
                     {
                         _value.set(value);
+                        _dirty = true;
                         notifyListeners(Control::Listener::VALUE_CHANGED);
                     }
                 }
@@ -146,6 +149,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 if (_value != value)
                 {
                     _value.set(value);
+                    _dirty = true;
                     notifyListeners(Control::Listener::VALUE_CHANGED);
                 }
 
@@ -161,6 +165,12 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
 void Joystick::update(const Control* container, const Vector2& offset)
 {
     Control::update(container, offset);
+
+    _clearBounds.x -= _radius;
+    _clearBounds.y -= _radius;
+    float radiusx2 = _radius + _radius;
+    _clearBounds.width += radiusx2;
+    _clearBounds.height += radiusx2;
 }
 
 void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)