Table of Contents

SHSplashScreen

type:
extension
author:
Shilo White
description:
A simple splash screen.
lastupdate:
2011-03-26
compatible:
v1.X
tag:
splash, splashscreen, advertisement, logo
homepage:
https://gist.github.com/888135
download:
https://gist.github.com/gists/888135/download
sample:
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

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.

Instructions

To add into your Sparrow project

  1. Download the source files here: https://gist.github.com/gists/888135/download
  2. Open your desired Sparrow project
  3. Drag and drop the files into the “Groups & Files” pane
  4. Open “Game.h”
  5. Include the extension:
    #include "SHSplashScreen.h"
  6. Save “Game.h”

To add directly into Sparrow source

  1. Download the source files here: https://gist.github.com/gists/888135/download
  2. Save the files into Sparrow's “/Classes/” directory
    • Example: “/sparrow/src/Classes/”
  3. Navigate back one directory and open “Sparrow.xcodeproj”
    • Example: “/sparrow/src/Sparrow.xcodeproj”
  4. Inside the “Groups & Files” pane, locate the “Display” group folder
    • Example: “Sparrow → Classes → Display”
  5. Right click the “Display” group folder and click “Add → Existing Files..”
  6. Navigate into the “/Classes/” directory and select “SHSplashScreen.h” and “SHSplashScreen.m”, then click “add”
  7. On the next window, leave all options as default and click “add”
  8. In the “Groups & Files” pane, Open “Sparrow.h”
    • Example “Sparrow → Classes → Sparrow.h”
  9. At the bottom of the file, add:
    #import "SHSplashScreen.h"
  10. Save “Sparrow.h”
  11. Close “Sparrow.xcodeproj”

Source Code

Changelog

Todo


API Reference

Inherits from SPSprite : SPDisplayObjectContainer : SPDisplayObject : SPEventDispatcher : 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 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 for more detail.

@property (nonatomic, assign) SHSplashScreenTransition startTransition

Default Value
SHSplashScreenTransitionFade

endTransition

The end transition as SHSplashScreenTransition. See 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

SHSplashScreenTransitionZoom

SHSplashScreenTransitionSlideUp

SHSplashScreenTransitionSlideDown

SHSplashScreenTransitionSlideLeft

SHSplashScreenTransitionSlideRight

SHSplashScreenTransitionFadeUp

SHSplashScreenTransitionFadeDown

SHSplashScreenTransitionFadeLeft

SHSplashScreenTransitionFadeRight

SHSplashScreenTransitionZoomUp

SHSplashScreenTransitionZoomDown

SHSplashScreenTransitionZoomLeft

SHSplashScreenTransitionZoomRight

SHSplashScreenPhase

The current phase/state of the transitions.

typedef enum {    
	SHSplashScreenPhaseBegan,
	SHSplashScreenPhaseStartTransitionEnded,
	SHSplashScreenPhaseEndTransitionBegan,
	SHSplashScreenPhaseEnded,
} SHSplashScreenPhase;

SHSplashScreenPhaseBegan

SHSplashScreenPhaseStartTransitionEnded

SHSplashScreenPhaseEndTransitionBegan

SHSplashScreenPhaseEndTransitionEnded

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];