0

我正在构建一个游戏,我需要在其中添加一个通用的顶层图层作为其他图层的通用菜单。我正在使用 AndEngineCocos2dExtension。当前代码:

 public class LobbyLayer extends CCLayer {

    CPButton low, medium, high, friends, vip;
    CCSprite low_selected, medium_selected, high_selected, friends_selected,
            vip_selected;

    CCNode tables[];


    public LobbyLayer() throws IOException {



        CCSprite background = new CCSprite("gfx/bg.jpg");
        background.setPosition(400, 240);
        attachChild(background);

        CPTopLayer topLayer = new CPTopLayer();
        topLayer.setPosition(0,240);
        attachChild(topLayer);

这是我的第二层,我有一个welcomeLayer,它有一个按钮(LobbyLayer),topLayer 是我想要在lobbyLayer 顶部的层。

但是我在模拟器上得到了一个黑屏,没有topLayer它可以正常工作。请帮助。

4

2 回答 2

0

您可以指定图层的 z 值。我在父层中添加子层时使用过:

addChild(background,1);//z value 0

addChild(topLayer,5);//z value 5 so appear above background layer
于 2013-03-04T09:33:26.623 回答
0

我不确定您在哪个分支上,但 GLES2 不再使用图层。当我在 andengine.org/forums 中搜索 Cocos2dExtension 时,我发现:

http://www.andengine.org/forums/tools/porting-to-ios-t8450.html

我相信 cocos2d 扩展是这样我们可以使用 cocos builder 来构建菜单和东西,所以我们有一个图形界面。

这对你有帮助吗?

于 2013-03-01T16:09:50.197 回答