2013-07-25 105 views
1

我想實現等軸測視圖。看到圖像。如何設置CCLayer CCCamera屬性可以做到這一點? Rotate和Scale不能這樣做,因爲同時旋轉和縮放。 isometric關於cocos2d等距相機

回答

2

顯然,這是爲時已晚供您使用,但任何人利用谷歌搜索在看這個「cocos2d的等距變換旋轉扭曲」或類似的東西,好像我是:我想通了正確的傾斜和旋轉。由於缺乏對角線刻度或Z旋轉,因此需要採用雙層方法。對於JavaScript開發人員:這使得等距轉換的DrawNode成爲可能。我不確定這會對性能產生什麼影響,但是由於它只使用本機功能,所以我不認爲它有多少功能。對於其他語言,它應該是微不足道的端口。

var MapContainer = cc.Layer.extend({ 
    ctor: function(){ 
    this._super(); 

    this.scaleX = .947; 
    this.setAnchorPoint({x:0, y:0}); 
    this.drawNode = new MapDrawNode(); 
    this.addChild(this.drawNode); 

    return true; 
    }, 
    drawNode: null 
}); 
var MapDrawNode = cc.DrawNode.extend({ 
    ctor: function(){ 
    this._super(); 

    this.setAnchorPoint({x:0, y:0}); 
    this.y = 360; // shifts everything up, adjust as needed. Mine is 1/2 window size 
    this.transform(); 

    // Your init code here 

    return true; 
    }, 
    transform: function(){ 
    this.setScaleX(0.81649658); 
    this.setScaleY(0.81649658); 
    this.setSkewX(16.3); 
    this.setSkewY(16.3); 
    this.setRotationY(45); 
    this.setRotationX(45); 
    } 
}); 

證明:檢查url處的圖像,因爲我沒有10個代表發佈它內聯。 http://i.stack.imgur.com/T3uU8.png