2013-02-28 71 views
0

我正在構建一個遊戲,其中我需要將一個通用topLayer作爲通用菜單添加到其他圖層。我正在使用AndEngineCocos2dExtension。 當前代碼:如何在另一個CCLayer的頂部添加一個CClayer android

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)按鈕,頂層是我要上lobbyLayer頂端的層。

但相反,我在模擬器上得到一個黑色的屏幕,它沒有topLayer.Please幫助它工作正常。

回答

0

我不確定你在哪個分支,但GLES2不再使用圖層。當我搜索Cocos2dExtension andengine.org/forums,這是我發現:

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

我相信cocos2d的擴展,所以我們可以用茯苓生成器生成菜單的之類的東西,所以我們有一個圖形接口。

這對你有幫助嗎?

0

您可以指定圖層的z值。我已經在添加父圖層中的子圖層時使用了:

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

addChild(topLayer,5);//z value 5 so appear above background layer