1. Cocos2dx 3.2 öw.vector, ValueMap, Touch '¥ 0000000000000000± ~äµä~~~ó~. iconv ×ö~± à ~â â  {

Source: Internet
Author: User

1. Cocos2dx 3.2 öw.vector, ValueMap, Touch '¥ 0000000000000000± ~äµä~~~ó~. iconv ×ö~± à ~â â  {
Zookeeper

  1. Cocos2dx3.2 commandid ° ó ~ó óã Vector 'Úomantáë CCArray £° À ~~~â £°

    Í Î ä¼ £° T02Vector. h

    # Ifndef _ T02Vector_H __

    # Define _ T02Vector_H __

    # Include "T32.h"

    ClassT02Vector: publicLayer

    {

    Public:

    CREATE_FUNC (T02Vector );

    // Cocos2dx3.2 commandid ° ó ¹ Ó Ã ó Vector 'ú~æ áë CCArray

    Vector _ Arr;

    Boolinit ();

    };

    # Endif

    ± À comment '£° T02Vector. cpp

    # Include "T02Vector. h"

    // In cocos3.2 Vector 'úú æ CCArray

    //  ç û ²» Ç çref µä×ó À £;ä äç²» äüó ?vector £ó Ó ?~~óstd: Vector

    BoolT02Vector: init ()

    {

    Layer: init ();

    Sprite * sprite = Sprite: create ();

    // Ö ö¼ Ó Ô Ø

    _ Arr. pushBack (sprite );

    // ± É À úo

    Vector : Iteratorit;

    For (it = _ arr. begin (); it! = _ Arr. end (); ++ it)

    {

    Sprite * s = * it;

    }

    For (autoit = _ arr. begin (); it! = _ Arr. end (); ++ it)

    {

    }

    For (autoit: _ arr)

    {

    }

    // ''° Óí ù ç° ± éáúo

    For (autoit = _ arr. rbegin (); it! = _ Arr. rend (); ++ it)

    {

    }

    // É ¾ ³ ý

    _ Arr. eraseObject (sprite );

    Returntrue;

    }

    2 Map maid? cocos ö ~~~***************************

    Í Î ä¼ £° T03Map. h

    # Ifndef _ T03Map_H __

    # Define _ T03Map_H __

    # Include "T32.h"

    ClassT03Map: publicLayer {

    Public:

    CREATE_FUNC (T03Map );

    Boolinit ();

    };

    # Endif

    ± À comment '£° T03Map. cpp

    # Include "T03Map. h"

    /*

    ValueMap Ç çó à À ''úú æ cocos2d. x µäccdictionary

    */

    BoolT03Map: init ()

    {

    Layer: init ();

    // Maid

    ValueMap & vm = FileUtils: getInstance ()-> getValueMapFromFile ("about. xml ");

    // CCDictionary * dict = CCDictionary: createWithContentsOfFile ("about. xml ");

    // Const CCString * x = dict-> valueForKey ("x ");

    // X-> intValue ();

    // ² É Õ Ò

    Autoit = vm. find ("aaa ");

    If (it = vm. end ())

    {

    CCLog ("can not find aaa ");

    }

    It = vm. find ("people3 ");

    It-> first; // key: Maid: string

    It-> second; // value: maid. 2.3 maid CCString

    CCLog ("key is % s, value is % s", it-> first. c_str (), it-> second. asString (). c_str ());

    CCLog ("... end ");

    Vm ["öð Î ä"] =" bbb ";

    CCLog ("... start walk over ");

    // ± É À úo

    For (autoit = vm. begin (); it! = Vm. end (); ++ it)

    {

    CCLog ("key is % s, value is % s", it-> first. c_str (), it-> second. asString (). c_str ());

    }

    CCLog ("... end ");

    FileUtils: getInstance ()-> writeToFile (vm, "new. xml ");

    # If 0

    // C ++ 11

    For (autoit: vm)

    {

    It. first;

    It. second;

    }

    // 2. ~~~~

    Vm ["aa"] = 10;

    // · Please refer to £ ;************************************************** ú£;ü ü» á'' ¨» ö öBB ~úµã

    Value & v = vm ["bb"];

    V = 100;

    Vm ["bb"] = false;

    # Endif

    Returntrue;

    }

    Ó Ã µäabout. xml %%%â £°

    People1

    Guímañañean zookeeper × zookeeper ~ögou ·

    People2

    ×U ¼ à £° Ð í ¼ n Ò ô

    People3

    Please refer to the following link for more information:

    People4

    À Ê õ £° Â í ¿¡

    People5

    ¸ Ä±à £° à ¼ ¶

    3 T04Label maid

    Í Î ä¼ £° T04Label. h

    # Ifndef _ T04Label_H __

    # Define _ T04Label_H __

    # Include "T32.h"

    ClassT04Label: publicLayer {

    Public:

    CREATE_FUNC (T04Label );

    Boolinit ();

    };

    # Endif

    ± À comment '£° T04Label. cpp

    # Include "T04Label. h"

    BoolT04Label: init ()

    {

    Layer: init ();

    {

    Label * label = Label: createWithCharMap ("fonts/Labelatlas.png", 24, 32, '0 ');

    Label> setString ("12345 ");

    AddChild (label );

    Label-> setPosition (winSize. width/2, winSize. height/2 );

    }

    # If 0

    Label * label = Label: createWithBMFont ();

    Label * label = Label: createWithSystemFont ("aaa", "Arial", 24 );

    Label * label = Label: createWithTTF ("");

    # Endif

    // Label * label = Label: createWithTexture ()

    Returntrue;

    }

    Please refer to the following example for more information: ***********************************************

    3 T05Touch '¥ {{}â {********

    VcmRlcj0 = "1" cellspacing = "0" cellpadding = "0">

    Í Î ää £° T05Touch. h

    # Ifndef _ T05Touch_H __

    # Define _ T05Touch_H __

    # Include "T32.h"

    ClassT05Touch: publicLayer

    {

    Public:

    CREATE_FUNC (T05Touch );

    Boolinit ();

    VoidTouchEnded (Touch *, Event *);

    };

    # Endif

    ± À comment '£° T05Touch. cpp

    # Include "T05Touch. h"

    BoolT05Touch: init ()

    {

    Layer: init ();

    {

    // Optional» ° ã Ê Ó Õ â öööö· £ £****» Ö önode *********************************************

    EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create ();

    Ev-> onTouchBegan = [] (Touch *, Event *) {returntrue ;};

    // Ev-> onTouchEnded = [] (Touch *, Event *){};

    Ev-> onTouchEnded = CC_CALLBACK_2 (T05Touch: TouchEnded, this );

    _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, this );

    }

    # If 0

    {

    // **********************************

    EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create ();

    Ev-> setSwallowTouches (true );

    Ev-> onTouchBegan = [] (Touch *, Event *) {CCLog ("Touch Begin"); returntrue ;};

    _ EventDispatcher-> addEventListenerWithFixedPriority (ev,-128 );

    }

    # Endif

    {

    Sprite * node = Sprite: create ();

    AddChild (node );

    EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create ();

    Ev-> onTouchBegan = [] (Touch * touch, Event *){

    // You can call touch-> getLocation () µä½ Ê ½» 'n'? ±» n?

    Vec2pt = touch-> getLocation ();

    CCLog ("Sprite is touched, pt. x = % f, pt. y = % f", pt. x, pt. y );

    Returntrue;

    };

    // Ev-> onTouchEnded = [] (Touch *, Event *){};

    // Ev-> onTouchEnded = CC_CALLBACK_2 (T05Touch: TouchEnded, this );

    _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, node );

    }

    {

    EventListenerTouchAllAtOnce * ev = EventListenerTouchAllAtOnce: create ();

    Ev-> onTouchesBegan = [] (conststd: vector &, Event *){};

    _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, this );

    }

    Returntrue;

    }

    VoidT05Touch: TouchEnded (Touch *, Event *){

    }

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.