http://blog.csdn.net/it_man/article/details/38292925A component, or assembly, refers to a binary unit that can be deployed independently, typically in the form of a DLL . For large software systems, good component design can break down the system into smaller components, so that each development team can focus on a single component without caring for the entire system. Component design requires adherence to the following principles:
Reuse - release Equivalence principle (REP)
Th
("player.png ");AddChild (player, 0, tagSprite );[Cpp]// Here, a tag is set for the player genie for later quick retrieval.// Set the backgroundCCLayer * layer = CCLayerColor: layerWithColor (ccc4 (255, 0, 0,255 ));AddChild (layer,-1 );Player-> setPosition (ccp (20,150 ));Player-> runAction (CCJumpTo: actionWithDuration (4, ccp (300, 48), 100, 4 ));Layer-> runAction (CCRepeatForever: actionWithAction (CCAc
delay second delay time, the timer only refreshes the function body once and does not refresh again.
Perform the following operations:
// Only run once, and run the command after delay in seconds // scheduleonce (schedule_selector (helloworld: myupdate), 5.0); void scheduleonce (sel_schedule selector, float delay );
[4. Other operations]
Cancel, pause, and resume the timer.
Perform the following operations:
// This-> unscheduleupdate (); // sprite-> unscheduleallselectors (); void unschedule
I have encapsulated a class and it is a layer. If necessary, add the layer directly. // it is original in vain.
Header file
#pragma once#include "cocos2d.h"USING_NS_CC;const int kTagBackground=0;const int kTagClipNode=1;const int kTagTip=2;class TestLayer :public CCLayer{public:CREATE_FUNC(TestLayer);virtual bool init();virtual void registerWithTouchDispatcher();virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);CCClippingNode* clip;CCSprite* tip;};
Source File
# Include "TestLayer.
Blood records are often used, and there is no need to write them again, which is a waste of time. Here we use the latest API to write one for future calls.
The engine version used by the following code is cocos2d-x 3.0rc01. RADIAL
Sprite * bgSprite = Sprite: create ("red.png"); addChild (bgSprite, 1, 1); Sprite * hpSprite = Sprite: create ("green.png "); progresstage = progresstage: create (hpSprite); progressTimer-> setType (ProgressTimer: Type: RADIAL); progressTimer-> setReverseProgress (tr
autorelease object CCScene * scene = CCScene: create (); // 'player' is an autorelisted object HelloWorld * layer = HelloWorld: create (); // add layer as a child to scene-> addChild (layer ); // return the scene return scene;} // on "init" you Need to initialize your instancebool HelloWorld: init () {// 1. super init first if (! CCLayer: init () {return false;} CCSize visibleSize = CCDirector: sharedDirector ()-> getVisibleSize (); CCPoint origin = CCDirector: shareddire () -> getVisibleOrigin
corresponds to the CCTMXTiledMap type. This type of object can be used to perform various operations on the grid map. The following code adds the grid map object as a subnode of the scenario to the game scenario.
Effect:
Center the map and set an anchor for the map object.
CCTMXTiledMap* map = CCTMXTiledMap::create("iso-test1.tmx");map->setAnchorPoint(ccp(0.5f,0.5f));map->setPosition(ccp(visibleSize.width
background picture when the background picture//fourth parameter is not available, the latter three parameters can omit EditBox = Cceditbox::create (ccsize
(300,40), Ccscale9sprite::create ("9.9.png"), Ccscale9sprite::create ("8.9.png"));
Editbox->setposition (CCP (M_SIZE.WIDTH/2,M_SIZE.HEIGHT/2));
This->addchild (EditBox);
Set preset text editbox->setplaceholder ("Please input:");
Sets the color of the text font editbox->setfontcolor (CCC3 (2
add the template:
Create Drawnode Object
ccdrawnode *m_paa=ccdrawnode::create ();
Static cccolor4f green = {0, 1, 0, 1};
Static Ccpoint RECT[4]={CCP ( -50,50), CCP (50,50), CCP (50,-50), CCP ( -50,-50)};
Use the above data to save a 100x100 rectangular
m_paa->drawpolygon (rect, 4, green, 0, green);
Set to the
, color set to use the stroke color, respectively, in the target position out of the left and right 4 direction offset, and then cover our body label can be.
/*string text *fontname text font type *fontsize text size *color3 text color *linewidth the width of the stroke */cclabelttf* Hellowo
Rld::textaddstroke (const char* string, const char* fontname, float fontsize,const cccolor3b color3,float lineWidth)
{/* Body CCLABELTTF */cclabelttf* Center = cclabelttf::create (String, FontName,
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