Game Development Reference
In-Depth Information
As of now, the FSParallaxNode class, which provides the functionality of
parallax scrolling background is created and it's time to create objects in FSMyS-
cene to make a cool environment.
5. We will be adding two background layers BlueSky and WhiteMist, so create two
objects for each of them.
@property (nonatomic, strong)
FSParallaxNode*spaceBlueSkyParallaxNode;
@property (nonatomic, strong)
FSParallaxNode*spaceWhiteMistParallaxNode;
Add a method called addParallaxNodes and call it in the first line of the
init method of FSMyScene .
[self addParallaxNodes];
6. For two parallax nodes, we have to add the following two constants for their relat-
ive speeds.
static const float SPACE_BLUE_SKY_BG_VELOCITY = 20.0;
static const float SPACE_WHITE_MIST_BG_VELOCITY =
100.0;
In addParallaxNodes, make an array of blueSkyParallaxBack-
groundImages and create an object of FSParallax by passing the size of
the scene and velocity at which it is going to scroll.
- (void)addParallaxNodes
{
NSArray *blueSkyParallaxBackgroundNames =
@[@"SpaceBackground.png", @"SpaceBackground.png",];
self.spaceBlueSkyParallaxNode = [[FSParallaxNode
alloc]
initWithBackgrounds:blueSkyParallaxBackgroundNames
size:self.frame.size
speed:-SPACE_BLUE_SKY_BG_VELOCITY];
Search WWH ::




Custom Search