2013-05-15 42 views
0

在我的cocos2d iphone項目中,我試圖添加平鋪地圖。平鋪地圖只有一個圖像層。我想通過下面的代碼添加這個平鋪地圖。我的瓦片地圖在Cocos2d iphone:Tiledmap顯示空白顯示

-(id) init 
{ 
if((self=[super init])) { 
    theMape = [CCTMXTiledMap tiledMapWithTMXFile:@"demomap.tmx"]; 
    [self addChild:theMape z:1]; 
} 
return self; 
} 

和來源是:

<?xml version="1.0" encoding="UTF-8"?> 
<map version="1.0" orientation="orthogonal" width="20" height="180" tilewidth="32" tileheight="32"> 
<tileset firstgid="1" name="block" tilewidth="32" tileheight="32"> 
<image source="block.png" width="90" height="34"/> 
<tile id="0"> 
<properties> 
    <property name="type" value="base"/> 
</properties> 
</tile> 
</tileset> 
<imagelayer name="backgorund" width="20" height="180"> 
<image source="bgimage.png"/> 
</imagelayer> 
</map> 

,我已經在我的資源文件夾bgimage.png文件。

當它僅包含圖層時,它將顯示該圖層。我不知道這有什麼問題嗎?

回答

1

cocos2d-iphone不支持平鋪的圖像層,只有平鋪圖層。

+0

好,如果我們想要在背景中添加一些可滾動的圖像比我們如何實現呢? – Renaissance

+0

sprite或在後臺添加的tilemap – LearnCocos2D