====== SHSplashScreen ====== ---- dataentry extension ---- type : extension author_mail : shilo86@gmail.com Shilo White description : A simple splash screen. lastupdate_dt : 2011-03-26 compatible : v1.X depends : tags : splash, splashscreen, advertisement, logo homepage_url : https://gist.github.com/888135 download_url : https://gist.github.com/gists/888135/download sample_url : http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenSample.zip ---- ===== Description ===== SHSplashScreen class will allow you to create splash screens with only a few lines of code. You can set the start/end transitions, start/end transition times, idle time, and you can toggle on/off skipOnTouch or transitionOnTouch. This extension subclasses SPSprite, so you can add anything to the splash screen, whether it would be an image, movieclip, or other. ===== Sample ===== [[http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenSample.zip|{{http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenScreenshot.png}}]] * Project: [[http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenSample.zip|Splash Screen Showcase]] * Screenshot: [[http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenScreenshot.png|SplashScreenScreenshot.png]] * Recording: [[http://shilo.coarsemode.com/sparrow/extensions/shsplashscreen/SplashScreenRecording.mov|SplashScreenRecording.mov]] ===== Example ===== //initialize the splash screen with an idle time of 5.0f and default transitions SHSplashScreen *splashScreen = [SHSplashScreen splashScreenWithTime:5.0f]; //initialize and add an image to the splash screen SPImage *logo = [SPImage imageWithContentsOfFile:@"logo.png"]; [splashScreen addChild:logo]; //add the splash screen to the stage, it will automatically start and automatically remove itself from the stage when finished. [self addChild:splashScreen]; ===== Documentation ===== See [[#api_reference|API Reference]]. ===== Instructions ===== ==== To add into your Sparrow project ==== - Download the source files here: [[https://gist.github.com/gists/888135/download]] - Open your desired Sparrow project - Drag and drop the files into the "Groups & Files" pane - Open "Game.h" - Include the extension: #include "SHSplashScreen.h" - Save "Game.h" ==== To add directly into Sparrow source ==== - Download the source files here: [[https://gist.github.com/gists/888135/download]] - Save the files into Sparrow's "/Classes/" directory * Example: "/sparrow/src/Classes/" - Navigate back one directory and open "Sparrow.xcodeproj" * Example: "/sparrow/src/Sparrow.xcodeproj" - Inside the "Groups & Files" pane, locate the "Display" group folder * Example: "Sparrow -> Classes -> Display" - Right click the "Display" group folder and click "Add -> Existing Files.." - Navigate into the "/Classes/" directory and select "SHSplashScreen.h" and "SHSplashScreen.m", then click "add" - On the next window, leave all options as default and click "add" - In the "Groups & Files" pane, Open "Sparrow.h" * Example "Sparrow -> Classes -> Sparrow.h" - At the bottom of the file, add: #import "SHSplashScreen.h" - Save "Sparrow.h" - Close "Sparrow.xcodeproj" ===== Source Code ===== %gist(888135)% ===== Changelog ===== * //2011-03-25:// First version ===== Todo ===== * (EMPTY) ---- ===== API Reference ===== | Inherits from | [[http://doc.sparrow-framework.org/core/Classes/SPSprite.html|SPSprite]] : [[http://doc.sparrow-framework.org/core/Classes/SPDisplayObjectContainer.html|SPDisplayObjectContainer]] : [[http://doc.sparrow-framework.org/core/Classes/SPDisplayObject.html|SPDisplayObject]] : [[http://doc.sparrow-framework.org/core/Classes/SPEventDispatcher.html|SPEventDispatcher]] : [[http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html|NSObject]] | | Declared in | SHSplashScreen.h | ==== Overview ==== ---- SHSplashScreen will function similar to a SPSprite. After initializing, you can add children to the splash screen. Once you add the splash screen to the stage, it will automatically began the transitions. After the splash screen finishes the end transition, it will remove itself from the stage. You can set //skipOnTouch// or //transitionOnTouch// to allow users to end the splash screen on touch. You can also listen to each phase of the splash screen by listening to event type //SH_EVENT_TYPE_SPLASH_SCREEN//, see [[#events|Events]] for more detail.\\ ==== Instance Methods ==== ---- === init ==== Returns an initialized //SHSplashScreen// object that contains default properties. - (id)init === initWithTime: ==== Returns an initialized //SHSplashScreen// object that contains default properties and sets the idle time given, in seconds. - (id)initWithTime:(float)time\\ ==== Class Methods ==== ---- === splashScreen ==== Returns an auto-released initialized //SHSplashScreen// object that contains default properties. + (SHSplashScreen *)splashScreen === splashScreenWithTime: ==== Returns an auto-released initialized //SHSplashScreen// object that contains default properties and sets the idle time given, in seconds. + (SHSplashScreen *)splashScreenWithTime:(float)time\\ ==== Properties ==== ---- === startTransition ==== The start transition as SHSplashScreenTransition. See [[#constants|Constants]] for more detail. @property (nonatomic, assign) SHSplashScreenTransition startTransition **Default Value**\\ SHSplashScreenTransitionFade === endTransition ==== The end transition as SHSplashScreenTransition. See [[#constants|Constants]] for more detail. @property (nonatomic, assign) SHSplashScreenTransition endTransition **Default Value**\\ SHSplashScreenTransitionFade === time ==== The idle time in seconds, which is after the start transition and before the end transition. @property (nonatomic, assign) float time **Default Value**\\ 2.0f === startTransitionTime ==== The start transition time in seconds, which is before the idle time. @property (nonatomic, assign) float startTransitionTime **Default Value**\\ 0.5f === endTransitionTime ==== The end transition time in seconds, which is after the idle time. @property (nonatomic, assign) float endTransitionTime **Default Value**\\ 0.5f === skipOnTouch ==== Indicates if the splash screen will immediately end and be removed from the stage when the stage is touched. @property (nonatomic, assign) BOOL skipOnTouch **Default Value**\\ NO === transitionOnTouch ==== Indicates if the splash screen will begin the end transition when the stage is touched. @property (nonatomic, assign) BOOL transitionOnTouch **Default Value**\\ YES\\ ==== Constants ==== ---- === SHSplashScreenTransition ==== The transition for either the start transition or the end transition. typedef enum { SHSplashScreenTransitionFade, SHSplashScreenTransitionZoom, SHSplashScreenTransitionSlideUp, SHSplashScreenTransitionSlideDown, SHSplashScreenTransitionSlideLeft, SHSplashScreenTransitionSlideRight, SHSplashScreenTransitionFadeUp, SHSplashScreenTransitionFadeDown, SHSplashScreenTransitionFadeLeft, SHSplashScreenTransitionFadeRight, SHSplashScreenTransitionZoomUp, SHSplashScreenTransitionZoomDown, SHSplashScreenTransitionZoomLeft, SHSplashScreenTransitionZoomRight } SHSplashScreenTransition; SHSplashScreenTransitionFade * A fade transition. The start transition will increment the alpha value from 0 to 1.0. The end transition will increment the alpha value from 1.0 to 0. SHSplashScreenTransitionZoom * A zoom transition from the center of the screen. The start transition will increment the scale value from 0 to 1.0 and position the splash screen to the center of the screen while transitioning. The end transition will increment the scale value from 1.0 to 0 and position the splash screen to the center of the screen. SHSplashScreenTransitionSlideUp * A slide transition in an upwards motion. The start transition will increment the y value from the bottom of the screen to 0. The end transition will increment the y value from 0 to -height. SHSplashScreenTransitionSlideDown * A slide transition in a downwards motion. The start transition will increment the y value from the -height to 0. The end transition will increment the y value from 0 to the bottom of the screen. SHSplashScreenTransitionSlideLeft * A slide transition in an leftwards motion. The start transition will increment the x value from the far-right of the screen to 0. The end transition will increment the x value from 0 to -width. SHSplashScreenTransitionSlideRight * A slide transition in a rightwards motion. The start transition will increment the x value from the -width to 0. The end transition will increment the x value from 0 to the far-right of the screen. SHSplashScreenTransitionFadeUp * A slide transition in an upwards motion while fading. The start transition will increment the y value from the bottom of the screen to 0 while incrementing the alpha value from 0 to 1.0. The end transition will increment the y value from 0 to -height while incrementing the alpha value from 1.0 to 0. SHSplashScreenTransitionFadeDown * A slide transition in a downwards motion while fading. The start transition will increment the y value from the -height to 0 while incrementing the alpha value from 0 to 1. The end transition will increment the y value from 0 to the bottom of the screen while incrementing the alpha value from 1.0 to 0. SHSplashScreenTransitionFadeLeft * A slide transition in an leftwards motion while fading. The start transition will increment the x value from the far-right of the screen to 0 while incrementing the alpha value from 0 to 1.0. The end transition will increment the x value from 0 to -width while incrementing the alpha value from 1.0 to 0. SHSplashScreenTransitionFadeRight * A slide transition in a rightwards motion while fading. The start transition will increment the x value from the -width to 0 while incrementing the alpha value from 0 to 1.0. The end transition will increment the x value from 0 to the far-right of the screen while incrementing the alpha value from 1.0 to 0. SHSplashScreenTransitionZoomUp * A slide transition in an upwards motion while zooming. The start transition will increment the y value from the bottom of the screen to 0 while scaling from 0 to 1.0. The end transition will increment the y value from 0 to -height while scaling from 1.0 to 0. SHSplashScreenTransitionZoomDown * A slide transition in a downwards motion while zooming. The start transition will increment the y value from the -height to 0 while scaling from 0 to 1.0. The end transition will increment the y value from 0 to the bottom of the screen while scaling from 1.0 to 0. SHSplashScreenTransitionZoomLeft * A slide transition in an leftwards motion while zooming. The start transition will increment the x value from the far-right of the screen to 0 while scaling from 0 to 1.0. The end transition will increment the x value from 0 to -width while scaling from 1.0 to 0. SHSplashScreenTransitionZoomRight * A slide transition in a rightwards motion while zooming. The start transition will increment the x value from the -width to 0 while scaling from 0 to 1.0. The end transition will increment the x value from 0 to the far-right of the screen while scaling from 1.0 to 0. === SHSplashScreenPhase ==== The current phase/state of the transitions. typedef enum { SHSplashScreenPhaseBegan, SHSplashScreenPhaseStartTransitionEnded, SHSplashScreenPhaseEndTransitionBegan, SHSplashScreenPhaseEnded, } SHSplashScreenPhase; SHSplashScreenPhaseBegan * The splash screen has been added to the stage and began the start transition. SHSplashScreenPhaseStartTransitionEnded * The splash screen has completed the start transition and entered the idle state. SHSplashScreenPhaseEndTransitionBegan * The splash screen has completed the idle state and began the end transition. SHSplashScreenPhaseEndTransitionEnded * The splash screen has completed the end transition and will remove itself from stage. ==== Events ==== ---- === SHSplashScreenEvent === An event that gets dispatched when entering each //SHSplashScreenPhase//. You can listen to the event with event type //SH_EVENT_TYPE_SPLASH_SCREEN//. SHSplashScreen *splashScreen = [SHSplashScreen splashScreen]; [splashScreen addEventListener:@selector(onSplashScreenEvent:) atObject:self forType:SH_EVENT_TYPE_SPLASH_SCREEN];