Book Image

Cocos2d-x Cookbook

By : Akihiro Matsuura
Book Image

Cocos2d-x Cookbook

By: Akihiro Matsuura

Overview of this book

Table of Contents (18 chapters)
Cocos2d-x Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Making original transitions for popping scenes


Cocos2d-x has transition effects for pushing a scene. For some reason, it does not have transition effects for popping scenes. We'd like to transition with an effect for popping scenes after pushing scenes with effects. In this recipe, we will explain how to create an original transition for popping scenes.

Getting ready

In this recipe, you will understand how to pop a transition scene with effects. You will need a new class, so you have to make new class files called DirectorEx.h and DirectorEx.cpp and add them to your project.

How to do it...

Cocos2d-x has a transition scene with effects for pushing scenes. However, it does not have transition effects for popping scenes. Therefore, we create an original class called DirectorEx to create a transition effect for popping scenes. The code snippet is given next.

DirectorEx.h has the following code:

class DirectorEx : public Director
{
public:
  Scene* previousScene(void);
  void popScene(Scene* trans...