Browse Source

Merge branch 'dev' of github.com:oxygine/oxygine-framework into dev

dmuratshin 9 years ago
parent
commit
c78235d306

+ 1 - 1
examples/Demo/src/Counter.cpp

@@ -32,7 +32,7 @@ public:
 
     spTween add()
     {
-        OX_ASSERT(_running == false);
+        OX_ASSERT(!_running);
 
         _running = true;
         int next = (_current + 1) % 10;

+ 1 - 1
examples/Demo/src/TestBox9Sprite.h

@@ -29,7 +29,7 @@ public:
         sprite->addTween(Actor::TweenHeight(getHeight() - sprite->getY() - 10), 5000, -1, true, 2500);
 
 
-        //you could also define guides from xml
+        //You could also define guides from xml
         //<image file="box9.png" guideX1="50" guideX2="210" guideY1="50" guideY2="125" />
         sprite->setGuides(40, 160, 40, 160);
         addChild(sprite);

+ 9 - 9
examples/Demo/src/TestHttp.h

@@ -12,27 +12,27 @@ public:
 
     TestHttp()
     {
-        //testing http request with redirect
+        //Testing http GET request
         spWebImage image1 = new WebImage;
-        image1->load("http://graph.facebook.com/1373973107/picture?type=normal&return_ssl_resources=0");
+        image1->load("http://oxygine.org/img/madewith.png");
         image1->setSize(100, 100);
-        image1->setPosition(getStage()->getSize() / 2);
+        image1->setPosition(image1->getPosition() + Vector2(image1->getWidth() + 10, 0));
         image1->attachTo(content);
 
-        //testing https
+        //Testing http GET request with redirect
         spWebImage image2 = new WebImage;
-        image2->load("http://oxygine.org/img/madewith.png");
+        image2->load("http://graph.facebook.com/1373973107/picture?type=normal&return_ssl_resources=0");
         image2->setSize(100, 100);
-        image2->setPosition(image1->getPosition() + Vector2(image1->getWidth() + 10, 0));
+        image2->setPosition(getStage()->getSize() / 2);
         image2->attachTo(content);
 
-
-        //testing load to file
+        //Testing loading a file in memory
         spHttpRequestTask task = HttpRequestTask::create();
         task->setUrl("http://nist.time.gov/actualtime.cgi");
         task->addEventListener(HttpRequestTask::COMPLETE, CLOSURE(this, &TestHttp::dateTimeLoaded));
         task->run();
 
+        //Testing downloading a file to disk
         task = HttpRequestTask::create();
         task->setUrl("http://oxygine.org/emscripten/MPHello.js.gz");
         task->setFileName("somefile.abc");
@@ -49,7 +49,7 @@ public:
         _bar->setY(getStage()->getHeight() - _bar->getHeight());
         _bar->attachTo(content);
 
-
+        //Testing http POST
         task = HttpRequestTask::create();
         task->setUrl("http://oxygine.org/test/reply.php");
         vector<unsigned char> postBody;

+ 1 - 1
examples/Demo/src/TestInputText.h

@@ -12,7 +12,7 @@ public:
     TextWithBackground(const string& defText)
     {
         text = new TextField;
-        //text won't handle any touch event
+        //Don't handle input events on this Actor
         text->setInputEnabled(false);
 
         TextStyle style;

+ 42 - 38
examples/Demo/src/entry_point.cpp

@@ -1,8 +1,8 @@
 /**
-Attention!
-This file has Oxygine initialization stuff.
-If you just started you don't need to understand it exactly you could check it later.
-You could start from example.cpp and example.h it has main functions being called from there
+	Attention!
+	This file initializes the Oxygine engine.
+	If you just started here and don't understand the code completely, feel free to come back later.
+	You can start from example.cpp and example.h, which main functions are called from here.
 */
 #include "core/oxygine.h"
 #include "Stage.h"
@@ -14,46 +14,48 @@ You could start from example.cpp and example.h it has main functions being calle
 using namespace oxygine;
 
 
-//called each frame
+// This function is called each frame
 int mainloop()
 {
+    // It gets passed to our example game implementation
     example_update();
-    //update our stage
-    //update all actors. Actor::update would be called also for all children
+
+    // Update our stage
+    // Update all actors. Actor::update will also be called for all its children
     getStage()->update();
 
     if (core::beginRendering())
     {
         Color clearColor(32, 32, 32, 255);
         Rect viewport(Point(0, 0), core::getDisplaySize());
-        //render all actors. Actor::render would be called also for all children
+        // Render all actors inside the stage. Actor::render will also be called for all its children
         getStage()->render(clearColor, viewport);
 
         core::swapDisplayBuffers();
     }
 
-    //update internal components
-    //all input events would be passed to Stage::instance.handleEvent
-    //if done is true then User requests quit from app.
+    // Update engine-internal components
+    // If input events are available, they are passed to Stage::instance.handleEvent
+    // If the function returns true, it means that the user requested the application to terminate
     bool done = core::update();
 
     return done ? 1 : 0;
 }
 
-//it is application entry point
+// Application entry point
 void run()
 {
     ObjectBase::__startTracingLeaks();
 
-    //initialize Oxygine's internal stuff
+    // Initialize Oxygine's internal stuff
     core::init_desc desc;
     desc.title = "Oxygine Application";
 
 #if OXYGINE_SDL || OXYGINE_EMSCRIPTEN
-    //we could setup initial window size on SDL builds
+    // The initial window size can be set up here on SDL builds
     desc.w = 960;
     desc.h = 640;
-    //marmalade settings could be changed from emulator's menu
+    // Marmalade settings can be modified from the emulator's menu
 #endif
 
 
@@ -61,55 +63,57 @@ void run()
     core::init(&desc);
 
 
-    //create Stage. Stage is a root node
+    // Create the stage. Stage is a root node for all updateable and drawable objects
     Stage::instance = new Stage(true);
     Point size = core::getDisplaySize();
     getStage()->setSize(size);
 
-    //DebugActor is a helper actor node. It shows FPS, memory usage and other useful stuff
+    // DebugActor is a helper actor node. It shows FPS, memory usage and other useful stuff
     DebugActor::show();
 
-    //initialize this example stuff. see example.cpp
+    // Initializes our example game. See example.cpp
     example_init();
 
 #ifdef EMSCRIPTEN
     /*
-    if you build for Emscripten mainloop would be called automatically outside.
-    see emscripten_set_main_loop below
+    If you build for Emscripten, mainloop is called automatically and shouldn't be called here.
+    See emscripten_set_main_loop in the EMSCRIPTEN section below
     */
     return;
 #endif
 
 
-    //here is main game loop
+    // This is the main game loop.
     while (1)
     {
         int done = mainloop();
         if (done)
             break;
     }
-    //user wants to leave application...
-
-    //lets dump all created objects into log
-    //all created and not freed resources would be displayed
+    /*
+     If we get here, the user has requested the Application to terminate.
+     We dump and log all our created objects that have not been freed yet
+    */
     ObjectBase::dumpCreatedObjects();
 
-    //lets cleanup everything right now and call ObjectBase::dumpObjects() again
-    //we need to free all allocated resources and delete all created actors
-    //all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
-    //but now we want delete it by hands
+    /*
+	Let's clean up everything right now and call ObjectBase::dumpObjects() again.
+	We need to free all allocated resources and delete all created actors.
+	All actors/sprites are smart-pointer objects and don't need to be removed by hand.
+	But now we want to delete it by hand.
+	*/
 
-    //check example.cpp
+    // See example.cpp for the shutdown function implementation
     example_destroy();
 
 
     //renderer.cleanup();
 
-    /**releases all internal components and Stage*/
+    // Releases all internal components and the stage
     core::release();
 
-    //dump list should be empty now
-    //we deleted everything and could be sure that there aren't any memory leaks
+    // The dump list should be empty by now,
+    // we want to make sure that there aren't any memory leaks, so we call it again.
     ObjectBase::dumpCreatedObjects();
 
     ObjectBase::__stopTracingLeaks();
@@ -130,11 +134,11 @@ int main(int argc, char* argv[])
 #include "SDL_main.h"
 extern "C"
 {
-    int main(int argc, char* argv[])
-    {
-        run();
-        return 0;
-    }
+int main(int argc, char* argv[])
+{
+    run();
+    return 0;
+}
 };
 #endif
 

+ 33 - 135
examples/Demo/src/example.cpp

@@ -26,7 +26,6 @@
 #include "TestTouches.h"
 #include "TestColorFont.h"
 #include "TestTweenAlphaFade.h"
-#include "TestEdges.h"
 
 #ifdef __S3E__
 #include "s3eKeyboard.h"
@@ -35,8 +34,8 @@
 using namespace oxygine;
 
 
-//it is our resources
-//in real project you would have more than one Resources declarations.
+//This contains our resources
+//In a real project you would have more than one Resources declaration.
 //It is important on mobile devices with limited memory and you would load/unload them
 Resources resources;
 
@@ -106,148 +105,47 @@ public:
 
     void clicked(string id)
     {
-        if (id == "perf")
-        {
-            showTest(new PerfTest);
-        }
-        if (id == "tweens")
-        {
-            showTest(new TweensTest);
-        }
-        if (id == "drag")
-        {
-            showTest(new DragTest);
-        }
-        if (id == "drag2")
-        {
-            showTest(new Drag2Test);
-        }
-        if (id == "hittest")
-        {
-            showTest(new TestAlphaHitTest);
-        }
-        if (id == "manage_res")
-        {
-            showTest(new ManageResTest);
-        }
-        if (id == "r2t")
-        {
-            showTest(new TestRender2Texture);
-        }
-        if (id == "text")
-        {
-            showTest(new TestText);
-        }
-
-        if (id == "progress_bar")
-        {
-            showTest(new TestProgressBar);
-        }
-
-        if (id == "texture_format")
-        {
-            showTest(new TestTextureFormat);
-        }
-
-        if (id == "sliding")
-        {
-            showTest(new TestSliding);
-        }
-
-        if (id == "t2p")
-        {
-            showTest(new TestTexel2Pixel);
-        }
-        if (id == "edges")
-        {
-            showTest(new TestEdges);
-        }
-
-        if (id == "touches")
-        {
-            showTest(new TestTouches);
-        }
-
-        if (id == "box9sprite")
-        {
-            showTest(new TestBox9Sprite);
-        }
-
-        if (id == "cliprect")
-        {
-            showTest(new TestClipRect);
-        }
-
-        if (id == "usershader")
-        {
-            showTest(new TestUserShader);
-        }
-
-        if (id == "usershader2")
-        {
-            showTest(new TestUserShader2);
-        }
-
-        if (id == "mask")
-        {
-            showTest(new TestMask);
-        }
-
-        if (id == "polygon")
-        {
-            showTest(new TestPolygon);
-        }
-
-        if (id == "inputtext")
-        {
-            showTest(new TestInputText);
-        }
-
+        if (id == "perf") showTest(new PerfTest);
+        if (id == "tweens") showTest(new TweensTest);
+        if (id == "drag") showTest(new DragTest);
+        if (id == "drag2") showTest(new Drag2Test);
+        if (id == "hittest") showTest(new TestAlphaHitTest);
+        if (id == "manage_res") showTest(new ManageResTest);
+        if (id == "r2t") showTest(new TestRender2Texture);
+        if (id == "text") showTest(new TestText);
+        if (id == "progress_bar") showTest(new TestProgressBar);
+        if (id == "texture_format") showTest(new TestTextureFormat);
+        if (id == "sliding") showTest(new TestSliding);
+        if (id == "t2p") showTest(new TestTexel2Pixel);
+        if (id == "touches") showTest(new TestTouches);
+        if (id == "box9sprite") showTest(new TestBox9Sprite);
+        if (id == "cliprect") showTest(new TestClipRect);
+        if (id == "usershader") showTest(new TestUserShader);
+        if (id == "usershader2") showTest(new TestUserShader2);
+        if (id == "mask") showTest(new TestMask);
+        if (id == "polygon") showTest(new TestPolygon);
+        if (id == "inputtext") showTest(new TestInputText);
+        if (id == "http") showTest(new TestHttp);
+        if (id == "counter") showTest(new TestCounter);
+        if (id == "tweentext") showTest(new TestTweenText);
+        if (id == "tweenshine") showTest(new TestTweenShine);
+        if (id == "multicolorfont") showTest(new TestColorFont);
+        if (id == "tweenfade") showTest(new TestTweenAlphaFade);
         if (id == "openbrowser")
         {
             core::execute("http://oxygine.org/");
             setVisible(true);
         }
-
-        if (id == "http")
-        {
-            showTest(new TestHttp);
-        }
-
-        if (id == "counter")
-        {
-            showTest(new TestCounter);
-        }
-
-        if (id == "tweentext")
-        {
-            showTest(new TestTweenText);
-        }
-
-        if (id == "tweenshine")
-        {
-            showTest(new TestTweenShine);
-        }
-
-        if (id == "multicolorfont")
-        {
-            showTest(new TestColorFont);
-        }
-
-        if (id == "tweenfade")
-        {
-            showTest(new TestTweenAlphaFade);
-        }
     }
 };
 
 void example_preinit()
 {
     /**
-    There are 2 modes of loading and blending/rendering sprites: normal and premultiplied alpha.
+    There are 2 modes of loading and blending/rendering sprites: normal and pre-multiplied alpha.
     You should set it before loading any assets.
-    Premultiplied mode is more advanced and faster than normal. In this mode RGB pixels of textures premultiplying to alpha when textures are loading and using blend_premultiply_alpha as default Sprites blend option.
-    Default value is premultiplied = true
+    Pre-multiplied mode is more advanced and faster than normal. In this mode RGB pixels of textures pre-multiplying to alpha when textures are loading and using blend_premultiply_alpha as default Sprites blend option.
+    Default value is pre-multiplied = true
     http://blog.rarepebble.com/111/premultiplied-alpha-in-opengl/
 
     I set it to false to simplify shaders for UserShaderDemo
@@ -259,7 +157,7 @@ void example_preinit()
 
 void example_init()
 {
-    //load xml file with resources definition
+    //Load resources in xml file
     resources.loadXML("xmls/res.xml");
 
 
@@ -268,7 +166,7 @@ void example_init()
     Test::instance = new TestActor;
     getStage()->addChild(Test::instance);
 
-    //initialize http requests
+    //Initialize http requests
     HttpRequestTask::init();
 
 

+ 4 - 4
examples/Demo/src/test.cpp

@@ -9,8 +9,8 @@ spTest Test::instance;
 
 void Test::init()
 {
-    //mount additional file system with inner path "ext"
-    //it would be used for searching path in data/ext
+    //Mount additional file system with inner path "ext"
+    //Used for searching files in data/ext
     extfs.setPath(file::fs().getFullPath("ext").c_str());
     file::mount(&extfs);
 
@@ -20,7 +20,7 @@ void Test::init()
 
     HttpRequestTask::init();
 
-    //load logo from oxygine server
+    //Load logo from oxygine server
     spWebImage sp = new WebImage;
     sp->load("http://oxygine.org/test/logo.png");
     sp->setInputEnabled(false);
@@ -80,7 +80,7 @@ spButton createButtonHelper(spButton button, const std::string& txt, EventCallba
     button->setResAnim(Test::resourcesUI.getResAnim("button"));
     button->addEventListener(TouchEvent::CLICK, cb);
 
-    //create Actor with Text and it to button as child
+    //Create Actor with Text and add it to button as child
     spTextField text = createText(txt);
     text->setSize(button->getSize());
     text->attachTo(button);