Conclusion: Practice proves that the default coordinates of these three things are 0,0 the default anchor points are 0.5, 0.5.
BOOL Helloworld::init ()
{
bool BRet = false;
Do
{
cc_break_if (! Cclayer::init ());
Ccsprite * Sprite = ccsprite::create ("Image1.png");
This->addchild (sprite);
Obtains the Ccsprite the default coordinates, Ccsprite coordinates the time to use own anchor point position occupies on the coordinate.
Cclog ("Ccsprite.x=%f,ccsprite.y=%f", Sprite->getposition (). X,sprite->getposition (). y);
Gets the default anchor point for Ccsprite
cclog ("Sprite1anchor.x=%f,sprite1anchor.y=%f", Sprite->getanchorpoint () .x,sprite-> Getanchorpoint (). y);
Gets the default coordinates of the Cclayer
cclog ("Cclayer.x=%f,cclayer.y=%f", This->getposition (). X,this->getposition (). y);
Obtain the default anchor point
= This->getanchorpoint ()
of Cclayer Ccpoint. Cclog ("layeranchor.x=%f,layeranchor.y=%f", point.x,point.y);
BRet = true;
} while (0);
return bRet;
}
ccscene* Helloworld::scene ()
{
ccscene * scene = NULL;
Do
{
//' scene ' was an Autorelease object
scene = Ccscene::create ();
CC_BREAK_IF (! scene);
' Layer ' is a Autorelease object
HelloWorld *layer = Helloworld::create ();
CC_BREAK_IF (! layer);
Add layer as a child to scene
Scene->addchild (layer);
Layer->show ();
} while (0);
Return the scene return
scene;
}
void Helloworld::show ()
{
//obtain ccscene default coordinates
ccscene * scene = (Ccscene *) this->getparent ();
Cclog ("Ccscene.x=%f,ccscene.y=%f", Scene->getposition (). X,scene->getposition (). y);
Obtain the default anchor point
= Scene->getanchorpoint ()
of Ccscene Ccpoint. Cclog ("sceneanchor.x=%f,sceneanchor.y=%f", Point.x,point.y);
}
One thing that is very noteworthy here is the function ignoreachorpointforposition (), which means whether to ignore anchor points when setting the coordinates of a node (including Ccscene,cclayer,ccsprite). We all know that when we set the coordinates, we use the anchor point to occupy the coordinates, and if we ignore the anchor point, it is the position that occupies the coordinates in the lower left corner, or the anchor point is the point in the lower left corner. Query the official API to get the conclusion: this is a internal method, only used by Cclayer and Ccscene. Don ' t call it outside framework. The default value is False, while in Cclayer and Ccscene are true. The default value for this function is false, but for Ccscene and cclayer its value is true. If that's the case, we're setting the coordinates of Ccscene and Cclayer in the lower-left corner of the anchor, not (0.5,0.5). But for Ccsprite, the default value for this function is false, which is that the anchor is the default anchor point (0.5,0.5).