Cocos2d-x 3.x Learning (1)

Source: Internet
Author: User
Tags addchild

Recently in the Network Programming (java-c#), so suddenly to Cocos2d.x have an idea, bought the Jong Dirong "Coco2d-x 3.x game development Tour", feel good ~

So just record your study notes here.

(PASS: The development environment has been equipped, but I do not know why cocos2d in VS2015 is not available, had to make a virtual machine installation VS2012 play on the virtual machine ~ Fortunately, good computer ~)

1. Scene SWITCH: Director: Directing Class

Example: Loading the first scene: Runwithscene

Director::getinstance ()->runwithscene (scene);

2. Simple switching scenario: Replacescene

Director::getinstance ()->replacescene (scene);

3.menuCloseCallback: Is the callback function of the Close button ~ (the book says it will speak later ~)

4.TransitionSlideInT: Scene Class (for animated effects Oh ~)

Transitionslideint (float t, Scene *scene);

There are other, of course:

Transitionjumpzoom: Original scene Zoom out, new scene zoom in

TRANSITIONPROGRESSRADIALCCW: Switch counterclockwise

Transitionprogresshorizontal: Horizontal pointer Toggle

Transitionprogressinout: Switching from inside to outside

Transitioncrossfade: The original scene slowly disappears, the new scene also slowly appears

Transitiopageforward: page, Next;

TRANSITIONFADETR: Block toggle lower left corner

Transitionfadeup: The blinds from the bottom up

Transitionturnofftiles: block switch, everywhere

Transitionsplitrows: Separated rectangular cross-shift

Transitionfade: Fades (turns black), gradients appear

Flipxleftover: Overall horizontal rollover, from left to right

Zoomflipxleftover: Overall horizontal rollover, from left to right, and scaled by distance from field of view

Transitionshrinkgrow: The original scene is shrinking back, the new scene from the rear to appear

Transitionrotozoom: The original scene spiral back to shrink away, new scene spiral forward to enlarge the appearance

TRANSITIONMOVEINL: New scene moves from left to right into

TRANSITIONSLIDEINL: Old and new scenes move from left to right at the same time

5. The scene's propulsion and popup scene:

The above Replacescene function makes the scene switch, which causes the old scene to be freed (because a scenario in development may take up a lot of resources)

But this approach does not need to release the old scene, the old and new scenes are still stored in memory

For example: Pushsene function: the

Popscene function: Release the new scene, restore the old scene display

1 //HelloWorldScene.cpp Part2 voidHelloworld::menuclosecallback (ref*Psender)3 {4     //Advancing the scene5Director::getinstance ()Pushscene (Secondscene::createscene ());6 }7 8 //SenondScene.cpp Part9 BOOLSecondscene::init () {Tenlabel* label = Label::create ("Hi, is you Mutou?","Arial", +); OneLabel->setposition (CCP ( $, $)); A      This-addChild (label); -     /*Add button*/ -Menuitemimage *pcloseitem =Menuitemimage::create ( the         "Closenormal.png", -         "Closeselected.png", -          This, - menu_selector (secondscene::p opscene)); +Pcloseitem->setposition (CCP (Director::getinstance ()->getwinsize (). Width- -, -)); -  +menu* Pmenu =menu::create (Pcloseitem, NULL); APmenu->setposition (Point (0,0)); at      This->addchild (Pmenu,1); -     return true; -}

< Span id= "line59" >< Span class= "Start-tag" > < Span class= "Attribute-name" >

Cocos2d-x 3.x Learning (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.