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 replacing scenes


You know that Cocos2d-x has a lot of transitioning effects. However, if it does not have an effect that you need, it is difficult to create an original transitioning effect. However, you can create it if you have the basic knowledge of transitioning effects. In this recipe, we will show you how to create original transitions.

How to do it...

Even though Cocos2d-x has a lot of different types of Transition classes, you may not find a transition effect that you need. In this recipe, you can create an original transition effect such as opening a door. When the replacement of a scene begins, the previous scene is divided into two and open to the left or right.

You have to create new files named "TransactionDoor.h" and "TransactionDoor.cpp," and add them to your project.

TransactionDoor.h has the following code:

#ifndef __TRANSITIONDOOR_H__
#define __TRANSITIONDOOR_H__

#include "cocos2d.h"

NS_CC_BEGIN

class CC_DLL TransitionDoor : public TransitionScene...