Cocos2d-X 3.4 version-the game continues, the game starts again, return to the main interface to achieve the "Zhao cloud to fight", mit2 game to continue
To use the latest version of Cocos Studio2.1, You need to upgrade the engine to 3.4.
The following is an upgrade description of 3.4. The opportunity has no impact on our project, so we only need to create a project with a new engine,
We can even upgrade the engine by simply overwriting the classes and resources.
More optimized rendering process: improved 2D and 3D rendering. Fantasy Warrior3D can now run without the hack engine.
Smaller package size: on iOS and Android platforms, the third-party library libcurl is replaced with the system network library, and the iOS game package size is reduced from 5.6M to 4.3 M, android APK game package size reduced from 2.9M to 2.0 M
Cocos Package Manager: Engine expansion modular framework that makes Cocos2d-x-based extension easier to integrate and release, now GAF has been applied to this framework
Cone-based cropping: reduces rendering overhead by calculating and cropping invisible objects on the screen, and provides support for 4.0 full 3D and large-scale scenes.
In this section, I learned a lot from the blog of Evakaka. I used to make masks and never used it like this.
Method. Now, it's really simple and rude.
In general, the implementation of this function is very obvious in principle, but in the specific implementation
Yes.
We need to create a new Scene. When we press the tentative button, see the newly created Scene push,
The reason why we don't need replaceScene is that we can't start the game again when we press the tentative button.
GamepauseScene. h
//// GamepauseScene.h// Fight//// Created by Cytzrs on 15/2/5.////#ifndef __Fight__GamepauseScene__#define __Fight__GamepauseScene__#include <iostream>#include "cocos2d.h"#include "cocos-ext.h"USING_NS_CC_EXT;USING_NS_CC;class GamepauseScene : public Layer{public: static Scene* createScene(RenderTexture*); bool init(); CREATE_FUNC(GamepauseScene); void attackAct1(Ref *sender, Control::EventType controlEvent); void attackAct2(Ref *sender, Control::EventType controlEvent); void attackAct3(Ref *sender, Control::EventType controlEvent);//private:// ControlButton* attackBtn1;// ControlButton* attackBtn2;// ControlButton* attackBtn3;};#endif /* defined(__Fight__GamepauseScene__) */
GamepauseScene. cpp
/// GamepauseScene. cpp // Fight // Created by Cytzrs on 15/2/5. //// # include "GamepauseScene. h "# include" cocos-ext.h "USING_NS_CC_EXT; # include" HelloWorldScene. h "Scene * GamepauseScene: createScene (RenderTexture * render) {auto scene = Scene: create (); auto layer = GamepauseScene: create (); scene-> addChild (layer, 1); auto s = Director: getInstance ()-> getVisibleSize (); auto bg = Sprite: createWithTextu Re (render-> getSprite ()-> getTexture (); bg-> setPosition (s/2); bg-> setFlippedY (true); bg-> setColor (cocos2d:: Color3B: GRAY); scene-> addChild (bg); return scene;} bool GamepauseScene: init () {while (1) {if (! Layer: init () return false; auto s = Director: getInstance ()-> getVisibleSize (); ControlButton * attackBtn1 = ControlButton: create ("continue game ", "fonts/Marker Felt. ttf ", 30); attackBtn1-> setPosition (s/2); this-> addChild (attackBtn1, 7); attackBtn1-> addTargetWithActionForControlEvents (this, cccontrol_selector (GamepauseScene :: attackAct1), Control: EventType: TOUCH_DOWN); ControlButton * attackBtn2 = ControlButton: create ("re-game", "fonts/Marker Felt. ttf ", 30); attackBtn2-> setPosition (s. width/2, s. height/2-100); this-> addChild (attackBtn2, 7); attackBtn2-> addTargetWithActionForControlEvents (this, cccontrol_selector (GamepauseScene: attackAct2), Control: EventType :: TOUCH_DOWN); ControlButton * attackBtn3 = ControlButton: create ("back to main interface", "fonts/Marker Felt. ttf ", 30); attackBtn3-> setPosition (s. width/2, s. height/2-200); this-> addChild (attackBtn3, 7); attackBtn3-> addTargetWithActionForControlEvents (this, cccontrol_selector (GamepauseScene: attackAct3), Control: EventType :: TOUCH_DOWN); // attackBtn2 = ControlButton: create ("ATTACK", "fonts/Marker Felt. ttf ", 30); // attackBtn2-> setPosition (Vec2 (visibleSize. width-200, 100); // this-> addChild (attackBtn2, 7); // attackBtn3 = ControlButton: create ("ATTACK ", "fonts/Marker Felt. ttf ", 30); // attackBtn3-> setPosition (Vec2 (visibleSize. width-200, 100); // this-> addChild (attackBtn3, 7); return true;} return false;} void GamepauseScene: attackAct1 (Ref * sender, Control:: EventType controlEvent) {// auto scene = HelloWorld: createScene (); ctor: getInstance ()-> popScene ();} void GamepauseScene: attackAct2 (Ref * sender, control: EventType controlEvent) {auto scene = HelloWorld: createScene (); ctor: getInstance ()-> replaceScene (scene);} void GamepauseScene :: attackAct3 (Ref * sender, Control: EventType controlEvent) {// auto scene = HelloWorld: createScene (); // the main interface has not been created yet. For the moment, leave it blank. ctor :: getInstance ()-> popScene ();}
Engineering source code
PS: write more blogs to help yourself and help others!