浏览代码

Moved the gameplay splash image into the main gameplay res folder.
Fixed the aspect ratio issue with displaying the gameplay splash image.
Added a sleep function to Platform.
Added a method for displaying a splash screen for a minimum amount of time over the duration of a function call (typically Game::initialize).
Moved the default particle texture.

Chris Culy 13 年之前
父节点
当前提交
ddbafec5ea

+ 4 - 0
gameplay/gameplay.vcxproj

@@ -193,6 +193,10 @@
     <ClInclude Include="src\Viewport.h" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="res\logo_black.png" />
+    <None Include="res\logo_powered_black.png" />
+    <None Include="res\logo_powered_white.png" />
+    <None Include="res\logo_white.png" />
     <None Include="res\shaders\bumped-specular.fsh" />
     <None Include="res\shaders\bumped-specular.vsh" />
     <None Include="res\shaders\bumped.fsh" />

+ 12 - 0
gameplay/gameplay.vcxproj.filters

@@ -628,6 +628,18 @@
     <None Include="src\PlatformiOS.mm">
       <Filter>src</Filter>
     </None>
+    <None Include="res\logo_black.png">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\logo_powered_black.png">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\logo_powered_white.png">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\logo_white.png">
+      <Filter>res</Filter>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <None Include="src\PhysicsFixedConstraint.inl">

二进制
gameplay/res/logo_black.png


二进制
gameplay/res/logo_powered_black.png


二进制
gameplay/res/logo_powered_white.png


二进制
gameplay/res/logo_white.png


二进制
gameplay/res/textures/particle-default.png


+ 34 - 0
gameplay/src/Game.h

@@ -384,8 +384,42 @@ private:
     AudioController* _audioController;          // Controls audio sources that are playing in the game.
     PhysicsController* _physicsController;      // Controls the simulation of a physics scene and entities.
     std::priority_queue<TimeEvent, std::vector<TimeEvent>, std::less<TimeEvent> > _timeEvents; // Contains the scheduled time events.
+
+    friend class SplashDisplayer;
 };
 
+/**
+ * Used for displaying splash screens.
+ */
+class SplashDisplayer
+{
+public:
+
+    /**
+     * Displays a splash screen using the {@link Game#renderOnce} mechanism for at least the given amount of time.
+     * 
+     * @param instance See {@link Game#renderOnce}.
+     * @param method See {@link Game#renderOnce}.
+     * @param cookie See {@link Game#renderOnce}.
+     * @param time The minimum amount of time to display the splash screen (in milliseconds).
+     */
+    template <typename T> void run(T* instance, void (T::*method) (void*), void* cookie, long time);
+
+    /**
+     * Destructor.
+     */
+    ~SplashDisplayer();
+
+private:
+
+    long _time;
+    long _startTime;
+};
+
+#define displaySplash(instance, method, cookie, time) \
+    SplashDisplayer __##instance##SplashDisplayer; \
+    __##instance##SplashDisplayer.run(instance, method, cookie, time)
+
 }
 
 #include "Game.inl"

+ 14 - 0
gameplay/src/Game.inl

@@ -66,4 +66,18 @@ inline void Game::displayKeyboard(bool display)
     Platform::displayKeyboard(display);
 }
 
+template <typename T> void SplashDisplayer::run(T* instance, void (T::*method) (void*), void* cookie, long time)
+{
+    _time = time;
+    Game::getInstance()->renderOnce(instance, method, cookie);
+    _startTime = Game::getInstance()->getGameTime();
+}
+
+inline SplashDisplayer::~SplashDisplayer()
+{
+    long elapsedTime = Game::getInstance()->getGameTime() - _startTime;
+    if (elapsedTime < _time)
+        Platform::sleep(_time - (Game::getInstance()->getGameTime() - _startTime));
+}
+
 }

+ 1 - 1
gameplay/src/ParticleEmitter.cpp

@@ -53,7 +53,7 @@ ParticleEmitter* ParticleEmitter::create(const char* textureFile, TextureBlendin
     if (!texture)
     {
         // Use default texture.
-        texture = Texture::create("../gameplay/res/textures/particle-default.png", true);
+        texture = Texture::create("res/particle-default.png", true);
     }
     assert(texture);
 

+ 7 - 0
gameplay/src/Platform.h

@@ -123,6 +123,13 @@ public:
 
     static void keyEventInternal(Keyboard::KeyEvent evt, int key);
 
+    /**
+     * Sleeps synchronously for the given amount of time (in milliseconds).
+     *
+     * @param ms How long to sleep (in milliseconds).
+     */
+    static void sleep(long ms);
+
 private:
 
     /**

+ 5 - 0
gameplay/src/PlatformAndroid.cpp

@@ -848,6 +848,11 @@ void Platform::displayKeyboard(bool display)
         __displayKeyboard = false;
 }
 
+void Platform::sleep(long ms)
+{
+    usleep(ms * 1000);
+}
+
 }
 
 #endif

+ 7 - 0
gameplay/src/PlatformMacOS.mm

@@ -5,6 +5,8 @@
 #include "FileSystem.h"
 #include "Game.h"
 
+#include <unistd.h>
+
 #import <Cocoa/Cocoa.h>
 #import <QuartzCore/CVDisplayLink.h>
 #import <OpenGL/OpenGL.h>
@@ -687,6 +689,11 @@ void Platform::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned
     }
 }
 
+void Platform::sleep(long ms)
+{
+    usleep(ms * 1000);
+}
+
 }
 
 #endif

+ 6 - 0
gameplay/src/PlatformQNX.cpp

@@ -4,6 +4,7 @@
 #include "Platform.h"
 #include "FileSystem.h"
 #include "Game.h"
+#include <unistd.h>
 #include <sys/keycodes.h>
 #include <screen/screen.h>
 #include <input/screen_helpers.h>
@@ -1098,6 +1099,11 @@ void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
     Form::keyEventInternal(evt, key);
 }
 
+void Platform::sleep(long ms)
+{
+    usleep(ms * 1000);
+}
+
 }
 
 #endif

+ 5 - 0
gameplay/src/PlatformWin32.cpp

@@ -681,6 +681,11 @@ void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
     Form::keyEventInternal(evt, key);
 }
 
+void Platform::sleep(long ms)
+{
+    Sleep(ms);
+}
+
 }
 
 #endif

+ 7 - 0
gameplay/src/PlatformiOS.mm

@@ -5,6 +5,8 @@
 #include "FileSystem.h"
 #include "Game.h"
 
+#include <unistd.h>
+
 #import <UIKit/UIKit.h>
 #import <QuartzCore/QuartzCore.h>
 #import <CoreMotion/CoreMotion.h>
@@ -853,6 +855,11 @@ void Platform::displayKeyboard(bool display)
         else [__view dismissKeyboard];
     }
 }
+
+void Platform::sleep(long ms)
+{
+    usleep(ms * 1000);
+}
     
 }