[英]Why does Cocos2d-x not show the sprite the first time?
問題是什么? 第一次沒有顯示精靈。
playerSprite = Sprite::create("ip.png");
playerSprite->setPosition(Vec2(visibleSize.width/2,visibleSize.height));
//this->addChild(playerSprite,1);
auto body = PhysicsBody::createCircle
(playerSprite->getContentSize().width / 2.5);
body->setContactTestBitmask(true);
body->setDynamic(true);
playerSprite->setPhysicsBody(body);
this->addChild(playerSprite,0);
嘗試使用Sprite的另一個Z順序。 this-> addChild(playerSprite, TRY_WITH_SOME_LARGE_VALUE );`
並查看結果是否相同。
由於您對問題的定義不多,因此答案可能不正確。
首先,請確保正確放置圖像,並且圖像名稱中沒有錯別字。
playerSprite
position
在頂部的中間。 居中:
->setPosition(Point(visibleSize.widht * 0.5, visibleSize.height * 0.5));
如果這== Scene
您可以這樣做。
->setPosition(Point(this->getContentSize().width * 0.5, this->getContentSize().height * 0.5));
另外在添加Sprite
時,通過將zOrder
設置為更大的數字,確保上面沒有其他Sprite
this->addChild(playerSprite, 100);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.