Browse Source

Minor formatting and modernizing the code.
Close #2214.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
d368227648

+ 1 - 1
Source/Samples/51_Urho2DStretchableSprite/CMakeLists.txt

@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008-2017 the Urho3D project.
+# Copyright (c) 2008-2018 the Urho3D project.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal

+ 49 - 57
Source/Samples/51_Urho2DStretchableSprite/Urho2DStretchableSprite.cpp

@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2008-2017 the Urho3D project.
+// Copyright (c) 2008-2018 the Urho3D project.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -77,42 +77,42 @@ void Urho2DStretchableSprite::CreateScene()
     // Set camera's position
     cameraNode_->SetPosition(Vector3(0.0f, 0.0f, -10.0f));
 
-    Camera* camera = cameraNode_->CreateComponent<Camera>();
+    auto* camera = cameraNode_->CreateComponent<Camera>();
     camera->SetOrthographic(true);
 
-    Graphics* graphics = GetSubsystem<Graphics>();
+    auto* graphics = GetSubsystem<Graphics>();
     camera->SetOrthoSize((float)graphics->GetHeight() * PIXEL_SIZE);
 
     refSpriteNode_ = scene_->CreateChild("regular sprite");
     stretchSpriteNode_ = scene_->CreateChild("stretchable sprite");
 
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    Sprite2D* sprite = cache->GetResource<Sprite2D>("Urho2D/Stretchable.png");
-    if(sprite)
+    auto* cache = GetSubsystem<ResourceCache>();
+    auto* sprite = cache->GetResource<Sprite2D>("Urho2D/Stretchable.png");
+    if (sprite)
     {
-      refSpriteNode_->CreateComponent<StaticSprite2D>()->SetSprite(sprite);
+        refSpriteNode_->CreateComponent<StaticSprite2D>()->SetSprite(sprite);
 
-      auto stretchSprite = stretchSpriteNode_->CreateComponent<StretchableSprite2D>();
-      stretchSprite->SetSprite(sprite);
-      stretchSprite->SetBorder({25, 25, 25, 25});
+        auto stretchSprite = stretchSpriteNode_->CreateComponent<StretchableSprite2D>();
+        stretchSprite->SetSprite(sprite);
+        stretchSprite->SetBorder({25, 25, 25, 25});
 
-      refSpriteNode_->Translate2D(Vector2{-2.0f, 0.0f});
-      stretchSpriteNode_->Translate2D(Vector2{2.0f, 0.0f});
+        refSpriteNode_->Translate2D(Vector2{-2.0f, 0.0f});
+        stretchSpriteNode_->Translate2D(Vector2{2.0f, 0.0f});
     }
 }
 
 void Urho2DStretchableSprite::CreateInstructions()
 {
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-    UI* ui = GetSubsystem<UI>();
+    auto* cache = GetSubsystem<ResourceCache>();
+    auto* ui = GetSubsystem<UI>();
 
     // Construct new Text object, set string to display and font to use
-    Text* instructionText = ui->GetRoot()->CreateChild<Text>();
+    auto* instructionText = ui->GetRoot()->CreateChild<Text>();
     instructionText->SetText(
-            "Use WASD keys to transform, Tab key to cycle through\n"
-            "Scale, Rotate, and Translate transform modes. In Rotate\n"
-            "mode, combine A/D keys with Ctrl key to rotate about\n"
-            "the Z axis");
+        "Use WASD keys to transform, Tab key to cycle through\n"
+        "Scale, Rotate, and Translate transform modes. In Rotate\n"
+        "mode, combine A/D keys with Ctrl key to rotate about\n"
+        "the Z axis");
     instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 12);
 
     // Position the text relative to the screen center
@@ -123,7 +123,7 @@ void Urho2DStretchableSprite::CreateInstructions()
 
 void Urho2DStretchableSprite::SetupViewport()
 {
-    Renderer* renderer = GetSubsystem<Renderer>();
+    auto* renderer = GetSubsystem<Renderer>();
 
     // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
     SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
@@ -141,41 +141,37 @@ void Urho2DStretchableSprite::SubscribeToEvents()
     UnsubscribeFromEvent(E_SCENEUPDATE);
 }
 
-void Urho2DStretchableSprite::HandleUpdate(StringHash eventType, VariantMap& eventData)
+void Urho2DStretchableSprite::HandleUpdate(StringHash /*eventType*/, VariantMap& eventData)
 {
     using namespace Update;
 
     // Take the frame time step, which is stored as a float
     float timeStep = eventData[P_TIMESTEP].GetFloat();
 
-    switch(selectTransform_)
+    switch (selectTransform_)
     {
-    case 0:
-        ScaleSprites(timeStep);
+    case 0: ScaleSprites(timeStep);
         break;
-    case 1:
-        RotateSprites(timeStep);
+    case 1: RotateSprites(timeStep);
         break;
-    case 2:
-        TranslateSprites(timeStep);
+    case 2: TranslateSprites(timeStep);
         break;
-    default:
-        URHO3D_LOGERRORF("bad transform selection: %d", selectTransform_);
+    default: URHO3D_LOGERRORF("bad transform selection: %d", selectTransform_);
     }
 }
 
-void Urho2DStretchableSprite::OnKeyUp(StringHash eventType, VariantMap& eventData)
+void Urho2DStretchableSprite::OnKeyUp(StringHash /*eventType*/, VariantMap& eventData)
 {
     using namespace KeyUp;
 
     const auto key = eventData[P_KEY].GetInt();
 
-    if(key == KEY_TAB)
+    if (key == KEY_TAB)
     {
         ++selectTransform_;
         selectTransform_ %= 3;
     }
-    else if(key == KEY_ESCAPE)
+    else if (key == KEY_ESCAPE)
         engine_->Exit();
 }
 
@@ -185,16 +181,15 @@ void Urho2DStretchableSprite::TranslateSprites(float timeStep)
     static constexpr auto speed = 1.0f;
     const auto input = GetSubsystem<Input>();
     const auto left = input->GetKeyDown(KEY_A),
-               right = input->GetKeyDown(KEY_D),
-               up = input->GetKeyDown(KEY_W),
-               down = input->GetKeyDown(KEY_S);
+        right = input->GetKeyDown(KEY_D),
+        up = input->GetKeyDown(KEY_W),
+        down = input->GetKeyDown(KEY_S);
 
-    if(left || right || up || down)
+    if (left || right || up || down)
     {
         const auto quantum = timeStep * speed;
-        const auto translate = Vector2{
-            (left ? -quantum : 0.0f) + (right ? quantum : 0.0f),
-            (down ? -quantum : 0.0f) + (up ? quantum : 0.0f)};
+        const auto translate = Vector2{(left ? -quantum : 0.0f) + (right ? quantum : 0.0f),
+                                       (down ? -quantum : 0.0f) + (up ? quantum : 0.0f)};
 
         refSpriteNode_->Translate2D(translate);
         stretchSpriteNode_->Translate2D(translate);
@@ -207,20 +202,18 @@ void Urho2DStretchableSprite::RotateSprites(float timeStep)
 
     const auto input = GetSubsystem<Input>();
     const auto left = input->GetKeyDown(KEY_A),
-               right = input->GetKeyDown(KEY_D),
-               up = input->GetKeyDown(KEY_W),
-               down = input->GetKeyDown(KEY_S),
-               ctrl = input->GetKeyDown(KEY_CTRL);
+        right = input->GetKeyDown(KEY_D),
+        up = input->GetKeyDown(KEY_W),
+        down = input->GetKeyDown(KEY_S),
+        ctrl = input->GetKeyDown(KEY_CTRL);
 
-    if(left || right || up || down)
+    if (left || right || up || down)
     {
         const auto quantum = timeStep * speed;
 
-        const auto xrot = (up ? -quantum : 0.0f) + (down ? quantum: 0.0f);
-        const auto rot2 = (left ? -quantum: 0.0f) + (right ? quantum : 0.0f);
-        const auto totalRot = Quaternion{xrot,
-                                         ctrl ? 0.0f : rot2,
-                                         ctrl ? rot2 : 0.0f};
+        const auto xrot = (up ? -quantum : 0.0f) + (down ? quantum : 0.0f);
+        const auto rot2 = (left ? -quantum : 0.0f) + (right ? quantum : 0.0f);
+        const auto totalRot = Quaternion{xrot, ctrl ? 0.0f : rot2, ctrl ? rot2 : 0.0f};
 
         refSpriteNode_->Rotate(totalRot);
         stretchSpriteNode_->Rotate(totalRot);
@@ -233,15 +226,14 @@ void Urho2DStretchableSprite::ScaleSprites(float timeStep)
 
     const auto input = GetSubsystem<Input>();
     const auto left = input->GetKeyDown(KEY_A),
-               right = input->GetKeyDown(KEY_D),
-               up = input->GetKeyDown(KEY_W),
-               down = input->GetKeyDown(KEY_S);
-    if(left || right || up || down)
+        right = input->GetKeyDown(KEY_D),
+        up = input->GetKeyDown(KEY_W),
+        down = input->GetKeyDown(KEY_S);
+    if (left || right || up || down)
     {
         const auto quantum = timeStep * speed;
-        const auto scale = Vector2{
-            1.0f + (right ? quantum : left ? -quantum : 0.0f),
-            1.0f + (up ? quantum : down ? -quantum : 0.0f)};
+        const auto scale = Vector2{1.0f + (right ? quantum : left ? -quantum : 0.0f),
+                                   1.0f + (up ? quantum : down ? -quantum : 0.0f)};
 
         refSpriteNode_->Scale2D(scale);
         stretchSpriteNode_->Scale2D(scale);

+ 4 - 4
Source/Samples/51_Urho2DStretchableSprite/Urho2DStretchableSprite.h

@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2008-2017 the Urho3D project.
+// Copyright (c) 2008-2018 the Urho3D project.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -42,14 +42,14 @@ class Urho2DStretchableSprite : public Sample
 
 public:
     /// Construct.
-    Urho2DStretchableSprite(Context* context);
+    explicit Urho2DStretchableSprite(Context* context);
 
     /// Setup after engine initialization and before running the main loop.
-    virtual void Start() override;
+    void Start() override;
 
 protected:
     /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
-    virtual String GetScreenJoystickPatchString() const override { return
+    String GetScreenJoystickPatchString() const override { return
         "<patch>"
         "    <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />"
         "    <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">TAB</replace>"

+ 10 - 10
Source/Urho3D/AngelScript/Urho2DAPI.cpp

@@ -51,7 +51,7 @@
 #include "../Urho2D/RigidBody2D.h"
 #include "../Urho2D/Sprite2D.h"
 #include "../Urho2D/SpriteSheet2D.h"
-#include "../Urho2D/StretchableSprite2D.h"
+#include "../Urho2D/StretchableSprite2D.h"
 #include "../Urho2D/TileMap2D.h"
 #include "../Urho2D/TileMapLayer2D.h"
 #include "../Urho2D/TmxFile2D.h"
@@ -171,13 +171,13 @@ static void RegisterAnimatedSprite2D(asIScriptEngine* engine)
     engine->RegisterObjectMethod("AnimatedSprite2D", "float get_speed() const", asMETHOD(AnimatedSprite2D, GetSpeed), asCALL_THISCALL);
 }
 
-static void RegisterStretchableSprite2D(asIScriptEngine* engine)
-{
-    RegisterStaticSprite2D<StretchableSprite2D>(engine, "StretchableSprite2D");
-    engine->RegisterObjectMethod("StretchableSprite2D", "void set_border(const IntRect&in)", asMETHOD(StretchableSprite2D, SetBorder), asCALL_THISCALL);
-    engine->RegisterObjectMethod("StretchableSprite2D", "const IntRect& get_border() const", asMETHOD(StretchableSprite2D, GetBorder), asCALL_THISCALL);
-}
-
+static void RegisterStretchableSprite2D(asIScriptEngine* engine)
+{
+    RegisterStaticSprite2D<StretchableSprite2D>(engine, "StretchableSprite2D");
+    engine->RegisterObjectMethod("StretchableSprite2D", "void set_border(const IntRect&in)", asMETHOD(StretchableSprite2D, SetBorder), asCALL_THISCALL);
+    engine->RegisterObjectMethod("StretchableSprite2D", "const IntRect& get_border() const", asMETHOD(StretchableSprite2D, GetBorder), asCALL_THISCALL);
+}
+
 static ParticleEffect2D* ParticleEffect2DClone(const String& cloneName, ParticleEffect2D* ptr)
 {
     SharedPtr<ParticleEffect2D> clone = ptr->Clone(cloneName);
@@ -760,10 +760,10 @@ void RegisterUrho2DAPI(asIScriptEngine* engine)
     RegisterDrawable2D(engine);
     RegisterStaticSprite2D(engine);
 
+    RegisterStretchableSprite2D(engine);
+
     RegisterAnimationSet2D(engine);
     RegisterAnimatedSprite2D(engine);
-
-    RegisterStretchableSprite2D(engine);
 
     RegisterParticleEffect2D(engine);
     RegisterParticleEmitter2D(engine);

+ 36 - 55
Source/Urho3D/Urho2D/StretchableSprite2D.cpp

@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2008-2017 the Urho3D project.
+// Copyright (c) 2008-2018 the Urho3D project.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -37,9 +37,9 @@ namespace
 {
 
 void checkBorder(int border, float drawSize)
-{ /* not clamping yet, as drawSize may still change and come to accommodate
-     large borders */
-    if(border < 0 || border * PIXEL_SIZE > drawSize)
+{
+    /* not clamping yet, as drawSize may still change and come to accommodate large borders */
+    if (border < 0 || border * PIXEL_SIZE > drawSize)
         URHO3D_LOGWARNINGF("Border out of bounds (%d), may be clamped", border);
 }
 
@@ -47,23 +47,18 @@ Rect calcEffectiveBorder(const IntRect& border, const Vector2& drawSize)
 {
     Vector2 min{Clamp(border.left_ * PIXEL_SIZE, 0.0f, drawSize.x_),
                 Clamp(border.bottom_ * PIXEL_SIZE, 0.0f, drawSize.y_)};
-    return Rect{
-        min,
-        {Clamp(border.right_ * PIXEL_SIZE, 0.0f, drawSize.x_ - min.x_),
-         Clamp(border.top_ * PIXEL_SIZE, 0.0f, drawSize.y_ - min.y_)} // max
-    };
+    return Rect{min, {Clamp(border.right_ * PIXEL_SIZE, 0.0f, drawSize.x_ - min.x_),
+                      Clamp(border.top_ * PIXEL_SIZE, 0.0f, drawSize.y_ - min.y_)} /* max*/ };
 }
 
-void prepareXYCoords(float coords[4], float low, float high,
-                     float lowBorder,
-                     float highBorder, float scale)
+void prepareXYCoords(float coords[4], float low, float high, float lowBorder, float highBorder, float scale)
 {
     coords[0] = low * scale;
     coords[3] = high * scale;
 
     auto scaleSign = Sign(scale);
     auto borderSize = lowBorder + highBorder;
-    if(borderSize > scaleSign * (coords[3] - coords[0]))
+    if (borderSize > scaleSign * (coords[3] - coords[0]))
     {
         auto size = high - low;
         coords[1] = coords[2] = scale * (low + (lowBorder * size / borderSize));
@@ -76,9 +71,7 @@ void prepareXYCoords(float coords[4], float low, float high,
     }
 }
 
-void prepareUVCoords(float coords[4], float low, float high,
-                     float lowBorder,
-                     float highBorder, float drawSize)
+void prepareUVCoords(float coords[4], float low, float high, float lowBorder, float highBorder, float drawSize)
 {
     coords[0] = low;
     coords[1] = low + lowBorder / drawSize;
@@ -86,16 +79,14 @@ void prepareUVCoords(float coords[4], float low, float high,
     coords[3] = high;
 }
 
-void prepareVertices(Vertex2D vtx[4][4], const float xs[4], const float ys[4],
-                     const float us[4], const float vs[4], unsigned color,
-                     const Vector3& position, const Quaternion& rotation)
+void prepareVertices(Vertex2D vtx[4][4], const float xs[4], const float ys[4], const float us[4], const float vs[4], unsigned color,
+    const Vector3& position, const Quaternion& rotation)
 {
-    for(unsigned i = 0; i < 4; ++i)
+    for (unsigned i = 0; i < 4; ++i)
     {
-        for(unsigned j = 0; j < 4; ++j)
+        for (unsigned j = 0; j < 4; ++j)
         {
-            vtx[i][j].position_ =
-                position + rotation * Vector3{xs[i], ys[j], 0.0f};
+            vtx[i][j].position_ = position + rotation * Vector3{xs[i], ys[j], 0.0f};
             vtx[i][j].color_ = color;
             vtx[i][j].uv_ = Vector2{us[i], vs[j]};
         }
@@ -104,20 +95,20 @@ void prepareVertices(Vertex2D vtx[4][4], const float xs[4], const float ys[4],
 
 void pushVertices(Vector<Vertex2D>& target, const Vertex2D source[4][4])
 {
-    for(unsigned i = 0; i < 3; ++i) // iterate over 3 columns
+    for (unsigned i = 0; i < 3; ++i) // iterate over 3 columns
     {
-        if(!Equals(source[i][0].position_.x_,
-                   source[i+1][0].position_.x_)) // if width != 0
+        if (!Equals(source[i][0].position_.x_,
+            source[i + 1][0].position_.x_)) // if width != 0
         {
-            for(unsigned j = 0; j < 3; ++j) // iterate over 3 lines
+            for (unsigned j = 0; j < 3; ++j) // iterate over 3 lines
             {
-                if(!Equals(source[0][j].position_.y_,
-                           source[0][j+1].position_.y_)) // if height != 0
+                if (!Equals(source[0][j].position_.y_,
+                    source[0][j + 1].position_.y_)) // if height != 0
                 {
-                    target.Push(source[i][j]);     // V0 in V1---V2
-                    target.Push(source[i][j+1]);   // V1 in |   / |
-                    target.Push(source[i+1][j+1]); // V2 in | /   |
-                    target.Push(source[i+1][j]);   // V3 in V0---V3
+                    target.Push(source[i][j]);          // V0 in V1---V2
+                    target.Push(source[i][j + 1]);      // V1 in |   / |
+                    target.Push(source[i + 1][j + 1]);  // V2 in | /   |
+                    target.Push(source[i + 1][j]);      // V3 in V0---V3
                 }
             }
         }
@@ -128,8 +119,8 @@ void pushVertices(Vector<Vertex2D>& target, const Vertex2D source[4][4])
 
 extern const char* URHO2D_CATEGORY;
 
-StretchableSprite2D::StretchableSprite2D(Context* context)
-    : StaticSprite2D{context}
+StretchableSprite2D::StretchableSprite2D(Context* context) :
+    StaticSprite2D{context}
 {
 }
 
@@ -138,8 +129,7 @@ void StretchableSprite2D::RegisterObject(Context* context)
     context->RegisterFactory<StretchableSprite2D>(URHO2D_CATEGORY);
 
     URHO3D_COPY_BASE_ATTRIBUTES(StaticSprite2D);
-    URHO3D_ACCESSOR_ATTRIBUTE("Border", GetBorder, SetBorder, IntRect,
-                              IntRect::ZERO, AM_DEFAULT);
+    URHO3D_ACCESSOR_ATTRIBUTE("Border", GetBorder, SetBorder, IntRect, IntRect::ZERO, AM_DEFAULT);
 }
 
 void StretchableSprite2D::SetBorder(const IntRect& border)
@@ -176,8 +166,7 @@ void StretchableSprite2D::UpdateSourceBatches()
      scaled, maintaining their relative size. The same principle applies for
      Y scaling (but with lines rather than columns). */
 
-    if(!sourceBatchesDirty_ || !sprite_ || (!useTextureRect_ &&
-        !sprite_->GetTextureRectangle(textureRect_, flipX_, flipY_)))
+    if (!sourceBatchesDirty_ || !sprite_ || (!useTextureRect_ && !sprite_->GetTextureRectangle(textureRect_, flipX_, flipY_)))
         return;
 
     Vector<Vertex2D>& vertices = sourceBatches_[0].vertices_;
@@ -188,24 +177,16 @@ void StretchableSprite2D::UpdateSourceBatches()
     float xs[4], ys[4], us[4], vs[4]; // prepare all coordinates
     const auto signedScale = node_->GetSignedWorldScale();
 
-    prepareXYCoords(xs, drawRect_.min_.x_, drawRect_.max_.x_,
-                    effectiveBorder.min_.x_, effectiveBorder.max_.x_,
-                    signedScale.x_);
-    prepareXYCoords(ys, drawRect_.min_.y_, drawRect_.max_.y_,
-                    effectiveBorder.min_.y_, effectiveBorder.max_.y_,
-                    signedScale.y_);
-
-    prepareUVCoords(us, textureRect_.min_.x_, textureRect_.max_.x_,
-                    effectiveBorder.min_.x_, effectiveBorder.max_.x_,
-                    drawRect_.max_.x_ - drawRect_.min_.x_);
-    prepareUVCoords(vs, textureRect_.min_.y_, textureRect_.max_.y_,
-                    -effectiveBorder.min_.y_,
-                    -effectiveBorder.max_.y_, // texture y direction inverted
-                    drawRect_.max_.y_ - drawRect_.min_.y_);
+    prepareXYCoords(xs, drawRect_.min_.x_, drawRect_.max_.x_, effectiveBorder.min_.x_, effectiveBorder.max_.x_, signedScale.x_);
+    prepareXYCoords(ys, drawRect_.min_.y_, drawRect_.max_.y_, effectiveBorder.min_.y_, effectiveBorder.max_.y_, signedScale.y_);
+
+    prepareUVCoords(us, textureRect_.min_.x_, textureRect_.max_.x_, effectiveBorder.min_.x_, effectiveBorder.max_.x_,
+        drawRect_.max_.x_ - drawRect_.min_.x_);
+    prepareUVCoords(vs, textureRect_.min_.y_, textureRect_.max_.y_, -effectiveBorder.min_.y_,
+        -effectiveBorder.max_.y_ /* texture y direction inverted*/, drawRect_.max_.y_ - drawRect_.min_.y_);
 
     Vertex2D vtx[4][4]; // prepare all vertices
-    prepareVertices(vtx, xs, ys, us, vs, color_.ToUInt(),
-                    node_->GetWorldPosition(), node_->GetWorldRotation());
+    prepareVertices(vtx, xs, ys, us, vs, color_.ToUInt(), node_->GetWorldPosition(), node_->GetWorldRotation());
 
     pushVertices(vertices, vtx); // push the vertices that make up each patch
 

+ 2 - 2
Source/Urho3D/Urho2D/StretchableSprite2D.h

@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2008-2017 the Urho3D project.
+// Copyright (c) 2008-2018 the Urho3D project.
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -33,7 +33,7 @@ class URHO3D_API StretchableSprite2D : public StaticSprite2D
 
 public:
     /// Construct.
-    StretchableSprite2D(Context* context);
+    explicit StretchableSprite2D(Context* context);
     /// Register object factory. Drawable2D must be registered first.
     static void RegisterObject(Context* context);
 

+ 4 - 4
bin/Data/Scripts/51_Urho2DStretchableSprite.as

@@ -113,7 +113,7 @@ void HandleUpdate(StringHash eventType, VariantMap& eventData)
     // Take the frame time step, which is stored as a float
     float timeStep = eventData["TimeStep"].GetFloat();
 
-    switch(selectTransform)
+    switch (selectTransform)
     {
     case 0:
         ScaleSprites(timeStep);
@@ -150,7 +150,7 @@ void TranslateSprites(float timeStep)
                up = input.keyDown[KEY_W],
                down = input.keyDown[KEY_S];
 
-    if(left || right || up || down)
+    if (left || right || up || down)
     {
         const float quantum = timeStep * speed;
         const Vector2 translate = Vector2(
@@ -172,7 +172,7 @@ void RotateSprites(float timeStep)
                down = input.keyDown[KEY_S],
                ctrl = input.keyDown[KEY_CTRL];
 
-    if(left || right || up || down)
+    if (left || right || up || down)
     {
         const float quantum = timeStep * speed;
 
@@ -195,7 +195,7 @@ void ScaleSprites(float timeStep)
                right = input.keyDown[KEY_D],
                up = input.keyDown[KEY_W],
                down = input.keyDown[KEY_S];
-    if(left || right || up || down)
+    if (left || right || up || down)
     {
         const float quantum = timeStep * speed;
         const Vector2 scale = Vector2(