Day01 note using namespace cocos2d; = USING_NS_CC; generally, the following # ifndef _ MYLAYER_H __# define _ MYLAYER_H _ --------------- generally add a macro to the header file: public CCLayer generally adds a class to inherit CCLayer: init (); CCLabelTTF * plabel = CCLabelTTF: create ("sunda", "Arial", 36 ); // define a lableaddChild (plabel, 1); // Add a lableCCSize size = CCDirector: sharedDirector ()-> getWinSize () in the image scene (); // obtain the current coordinate plabel-> setPosition (ccp (size. width/2, size. height/2); // set the position of the lable on the stage // Add an image CCMenuItemImage: create ("CloseNormal.png", "CloseSelected.png", this, menu_selector (mylist:: menuCloseCallback); // The first parameter is the displayed image; // The second parameter is the image in the vertex; // The third parameter is the fourth parameter triggered when you click; plugin * inage = Plugin: create ("CloseNormal.png", "CloseSelected.png", this, menu_selector (mylist: menuCloseCallback); CCMenu * pMenu = CCMenu: create (inage, NULL); pMenu-> setPosition (); // The coordinate addChild (pMenu, 1) of the image; // display // Add a background CCSprite * pSprite = CCSprite :: create ("HelloWorld.png"); // Add an image pSprite-> setPosition (ccp (size. width/2, size. height/2); // set the position of the image addChild (pSprite, 0); // return true; setTouchEnabled (true ); supported touch: If not written, do not approve of the touch setTouchMode (kCCTouchesAllAtOnce); multi-touch: for example, what setTouchMode (kCCTouchesOneByOne) is pressed by both hands on the mobile phone screen; single-touch: for example, if you click bool ccTouchBegan (CCTouch * pTouch, CCEvent * pEvent) on the mobile phone screen with a single hand; // void ccTouchMoved (CCTouch * pTouch, CCEvent * pEvent) when your finger is pressed ); // void ccTouchEnded (CCTouch * pTouch, CCEvent * pEvent) when your fingers move and press; // void ccTouchCancelled (CCTouch * pTouch, CCEvent * pEvent); // when you call, the genie creates CCSprite * sprite = CCSprite: create ("1/furnace/jt.png "); use an image to directly create CCSprite * sprite = CCSprite: create ("1/furnace/jt.png", CCRectMake (, 20, 20 )); // use the same image, but use a part of CCRectMake (the starting point of x, the starting point of y, the end point of x, and the end point of y) addChild (sprite ); CCSize size = CCDirector: sharedDirector ()-> getWinSize (); // obtain the size of the stage sprite-> setPosition (ccp (size. width/2, size. height/2); // the location where the genie is sent // texture attribute CCTexture2D * texture = CCTextureCache: sharedTextureCache ()-> addImage ("1/furnace/jt.png "); // create a texture, put it in the texture cache, and return the cached object CCSprite * sprite = CCSprite: createWithTexture (texture); // It is equivalent to sending the image to the memory, you can use CCSprite * sprite = CCSprite: createWithTexture (texture, CCRectMake (, 20, 20) multiple times )); // use the same image, but use a part of CCRectMake (the start point of x, the start point of y, the end point of x, and the end point of y) CCSpriteFrame * frame = CCSpriteFrame :: createWithTexture (texture, CCRectMake (100,100,); // The needle is part of the texture CCSprite * sprite = CCSprite: create ("Images/blocks.png "); // The URL for creating a sprite image must be Images/blocks.png addChild (sprite); sprite-> setPosition (ccp (100,100); // The base point must be in the lower right corner, sprite-> setAnchorPoint (ccp (0.5); // 1. The sprite's profile is (0.5,) by default and is not an absolute coordinate value, /0 is the lower right foot // is the lower left foot // scaling attribute sprite-> setScale (1.5f); // It means scaling the image sprite-> setScaleX (0.5f ); // X-axis scaling sprite-> setScaleY (0.5f); // y-axis scaling // rotation attribute sprite-> setRotation (90.f ); if the integer is positive, the negative number is rotated counterclockwise. sprite-> setRotationX (90.f); Y axis is rotated by 90. degree is no sprite-> setRotationY (90.f); Y axis rotation 90. degrees are gone // distortion attributes sprite-> setSkewX (601_f); X axis is distorted by 60 degrees, but if it is distorted to 90 degrees, no sprite-> setSkewY (601_f ); if the Y axis is 60 degrees distorted but it is 90 degrees distorted, there is no difference between rotation and twisting. If you rotate to 180 degrees and twist to 180 degrees, the rotation will change, but the distortion won't // flip sprite-> setFlipX (true); is X axis flip sprite-> setFlipY (true); is Y axis flip // transparent sprite-> setOpacity (1 ); the range is between 0 and 255. 0 indicates full transparency, and 255 indicates opacity. // The color sprite-> setColor (ccc3 (, 0, 0); // ccc3 (, 0 ), the parameters are RGB red, yellow, green // visible property sprite-> setVisible (false ); // false indicates the invisible property. // ture indicates the visible property. // specifies the sprite-> setDisplayFrame (...); // extended the user data attribute. the cocos system uses char * buf = "helloword"; sprite-> setUserData (buf); char * p = (char *) sprite-> getUserData (); CCLOG ("user data is % s", p); // sets the associated object sprite-> setUserObject (sprite );