简体   繁体   中英

How to add label or sprite over another sprite in cocos2d android?

CCSprite butonSprite=CCSprite.sprite("magnet.png");
    CCLabel label1=CCLabel.makeLabel("START", "Arial", 30);
    label1.setPosition(0,0);
    butonSprite.addChild(label1);

    ccMacros.CCLOG("", ""+butonSprite.getChildren());

    CCMenuItemSprite item=CCMenuItemSprite.item(butonSprite, butonSprite,this,"goToGameScreen");
    CCMenu menu=CCMenu.menu(item);

Only the sprite is visible. How to make the label visible? i tried setting position to label.

Your label may be is beneath the position of the sprite, try to change the z-ordering greater than z-ordering of the sprite

eg

[sprite addChild:label z: 10];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM