Browse Source

Clean up CharacterDemo sample to use the same TOUCH_SENSITIVITY value.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
24e6b0d3cf

+ 3 - 3
Source/Samples/18_CharacterDemo/CharacterDemo.cpp

@@ -23,7 +23,6 @@
 #include "AnimatedModel.h"
 #include "AnimatedModel.h"
 #include "AnimationController.h"
 #include "AnimationController.h"
 #include "Camera.h"
 #include "Camera.h"
-#include "Character.h"
 #include "CollisionShape.h"
 #include "CollisionShape.h"
 #include "Controls.h"
 #include "Controls.h"
 #include "CoreEvents.h"
 #include "CoreEvents.h"
@@ -43,11 +42,12 @@
 #include "Scene.h"
 #include "Scene.h"
 #include "StaticModel.h"
 #include "StaticModel.h"
 #include "Text.h"
 #include "Text.h"
-#include "Touch.h"
 #include "UI.h"
 #include "UI.h"
 #include "Zone.h"
 #include "Zone.h"
 
 
+#include "Character.h"
 #include "CharacterDemo.h"
 #include "CharacterDemo.h"
+#include "Touch.h"
 
 
 #include "DebugNew.h"
 #include "DebugNew.h"
 
 
@@ -70,7 +70,7 @@ void CharacterDemo::Start()
     // Execute base class startup
     // Execute base class startup
     Sample::Start();
     Sample::Start();
     if (touchEnabled_)
     if (touchEnabled_)
-        touch_ = new Touch(context_);
+        touch_ = new Touch(context_, TOUCH_SENSITIVITY);
 
 
     // Create static scene content
     // Create static scene content
     CreateScene();
     CreateScene();

+ 5 - 4
Source/Samples/18_CharacterDemo/Touch.cpp

@@ -20,18 +20,19 @@
 // THE SOFTWARE.
 // THE SOFTWARE.
 //
 //
 
 
-#include "Character.h"
 #include "Controls.h"
 #include "Controls.h"
 #include "Graphics.h"
 #include "Graphics.h"
 #include "Input.h"
 #include "Input.h"
 #include "Renderer.h"
 #include "Renderer.h"
+
+#include "Character.h"
 #include "Touch.h"
 #include "Touch.h"
 
 
-const float TOUCH_SENSITIVITY = 5.0f;
 const float GYROSCOPE_THRESHOLD = 0.1f;
 const float GYROSCOPE_THRESHOLD = 0.1f;
 
 
-Touch::Touch(Context* context) :
+Touch::Touch(Context* context, float touchSensitivity) :
     Object(context),
     Object(context),
+    touchSensitivity_(touchSensitivity),
     cameraDistance_(CAMERA_INITIAL_DIST),
     cameraDistance_(CAMERA_INITIAL_DIST),
     zoom_(false),
     zoom_(false),
     useGyroscope_(false)
     useGyroscope_(false)
@@ -69,7 +70,7 @@ void Touch::UpdateTouches(Controls& controls) // Called from HandleUpdate
                 sens = -1;
                 sens = -1;
             else
             else
                 sens = 1;
                 sens = 1;
-            cameraDistance_ += Abs(touch1->delta_.y_ - touch2->delta_.y_) * sens * TOUCH_SENSITIVITY / 50.0f;
+            cameraDistance_ += Abs(touch1->delta_.y_ - touch2->delta_.y_) * sens * touchSensitivity_ / 50.0f;
             cameraDistance_ = Clamp(cameraDistance_, CAMERA_MIN_DIST, CAMERA_MAX_DIST); // Restrict zoom range to [1;20]
             cameraDistance_ = Clamp(cameraDistance_, CAMERA_MIN_DIST, CAMERA_MAX_DIST); // Restrict zoom range to [1;20]
         }
         }
     }
     }

+ 3 - 1
Source/Samples/18_CharacterDemo/Touch.h

@@ -50,13 +50,15 @@ class Touch : public Object
 
 
 public:
 public:
     /// Construct.
     /// Construct.
-    Touch(Context* context);
+    Touch(Context* context, float touchSensitivity);
     /// Destruct.
     /// Destruct.
     ~Touch();
     ~Touch();
 
 
     /// Update touch controls for the current frame.
     /// Update touch controls for the current frame.
     void UpdateTouches(Controls& controls);
     void UpdateTouches(Controls& controls);
 
 
+    /// Touch sensitivity.
+    float touchSensitivity_;
     /// Current camera zoom distance.
     /// Current camera zoom distance.
     float cameraDistance_;
     float cameraDistance_;
     /// Zoom flag.
     /// Zoom flag.