September 2014
Beginner
266 pages
5h 38m
English
Next, all we have to do is include the ScrollingBgLayer class in HelloWorldScene.h.
In HelloWorldScene.h, add the ScrollingBg.h header file:
#include "ScrollingBgLayer.h"
Create a new variable of the ScrollingBgLayer type named scrollingBgLayer:
ScrollingBgLayer* scrollingBgLayer;
Next, in the HelloWorldScene.cpp file, initialize the variable in the init() function:
scrollingBgLayer = new ScrollingBgLayer(3.0);
this->addChild(scrollingBgLayer);Here, we give 3.0 as the base speed. The respective speeds of the different objects will be based on this speed.
Next, call the update function of ScrollingBgLayer in the HelloWorldScenes update function:
scrollingBgLayer->update();
Now if you build and run the project, you ...
Read now
Unlock full access