These two days saw the concept of the anchor point.
/**
* Sets the anchor point in percent.
*
* Anchorpoint is the point around which all transformations and positioning manipulations take place.
* It's like a pin in the node where It's "attached" to its parent.
* The anchorpoint is normalized, like a percentage. (0,0) means the bottom-left corner and () means the top-right corner.
* But your can use values higher than and lower than (0,0) too.
* The default anchorpoint is (0.5,0.5), so it starts in the center of the node.
*
* @param anchorpoint The anchor point of node.
*/
virtual void Setanchorpoint (const ccpoint& anchorpoint);
Anchorpoint is the point around which all transformations and positioning manipulations take place.
It is used for reference points when locating positions and flipping.
ccsprite* sprite5 = ccsprite::create ("Closenormal.png");
Sprite5->setanchorpoint (CCP (0.5,0.5));
Sprite5->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (SPRITE5);
At this time (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2)) point is the center point of the Sprite5 (CCP (0.5,0.5))
Ccsize visiblesize = Ccdirector::shareddirector ()->getvisiblesize ();
Ccpoint origin = Ccdirector::shareddirector ()->getvisibleorigin ();
upper right corner
ccsprite* sprite1 = ccsprite::create ("Closeselected1.png");
Sprite1->setanchorpoint (CCP (0,0));
Sprite1->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (SPRITE1);
Upper left corner
ccsprite* Sprite2 = ccsprite::create ("Closenormal.png");
Sprite2->setanchorpoint (CCP (1,0));
Sprite2->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (SPRITE2);
Lower left corner
ccsprite* sprite3 = ccsprite::create ("Closenormal.png");
Sprite3->setanchorpoint (CCP);
Sprite3->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (Sprite3);
Lower right corner
ccsprite* sprite4 = ccsprite::create ("Closenormal.png");
Sprite4->setanchorpoint (CCP (0,1));
Sprite4->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (SPRITE4);
Middle
ccsprite* sprite5 = ccsprite::create ("Closenormal.png");
Sprite5->setanchorpoint (CCP (0.5,0.5));
Sprite5->setposition (CCP (ORIGIN.X+VISIBLESIZE.WIDTH/2, ORIGIN.Y+VISIBLESIZE.HEIGHT/2));
This->addchild (SPRITE5);
The concept of Anchor point in cocos2d