This is the code
H file
# pragma once
# # ifndef __Login_SCENE_H__
# define __Login_SCENE_H__
# include "cocos2d. H"
The class Login: public cocos2d: : Layer
{
Public:
The static cocos2d: : Scene * createScene ();
Virtual bool init ();
//a selector that callback
Void menuCloseCallback (cocos2d: : Ref * pSender);
};
CREATE_FUNC (Login);
# endif//__Login_SCENE_H__
The CPP file
# include "LoginScene. H"
# include "SimpleAudioEngine. H"
# include "cocostudio/cocostudio. H"
# include "UI/CocosGUI. H"
USING_NS_CC;
Using the namespace cocostudio: : timeline;
Scene * Login: : createScene ()
{
//'scene' is an autorelease object
Auto scene=scene: : create ();
//'layer' is an autorelease object
Auto layer=Login: : create ();
//add layer as a child to scene
Scene - & gt; AddChild (layer);
//return the scene
Return the scene;
}
//on "init" you need to initialize your instance
Bool Login: : init ()
{
//////////////////////////////
//1. Super init first
if (! Layer: : init ())
{
return false;
}
Auto pNode=CSLoader: : createNode (" MainScene. The CSB ");
Auto rootNode=CSLoader: : createNode (" LoginScene. The CSB ");
This - & gt; AddChild (pNode);
This - & gt; AddChild (rootNode);
return true;
}
Void Login: : menuCloseCallback (Ref * pSender)
{
//Close the cocos2d - x game scene and quit the application
Director: : getInstance () - & gt; The end ();
# if (CC_TARGET_PLATFORM==CC_PLATFORM_IOS)
exit(0);
# endif
/* To navigate back To native iOS screen (if present) without quitting the application, do not use Director: : getInstance () - & gt; End () and exit (0) as given above, home trigger a custom event created in RootViewController. Mm as below */
//EventCustom customEndEvent (" game_scene_close_event ");
//_eventDispatcher - & gt; DispatchEvent (& amp; CustomEndEvent);
}
