[英]Cocos2d ClippingNode and Alphathreshold in Javascript / Browser
我正在嘗試TP在Cocos2d-JS中使用png作為蒙版,如下所示:
this.mask=cc.Sprite.create(cache.getSpriteFrame("bar_mask"));
this.maskedFill = cc.ClippingNode.create(this.mask);
this.maskedFill.setAlphaThreshold(0.5);
但這是行不通的...我在其他帖子中發現,我必須啟用像CCSetupDepthFormat這樣的模具緩沖區:@ GL_DEPTH24_STENCIL8_OES
但是我不知道如何/在Cocos2d-JS中做到這一點
有人可以幫忙嗎?
謝謝!
它對我有用,無需任何其他depthFormat設置。 我正在使用單文件引擎cocos2d-js-v3.7.js,這是最少的代碼(希望有幫助):
var game = cc.Layer.extend({
init:function () {
this._super();
backgroundLayer = cc.LayerColor.create(new cc.Color(40,40,40,255), 320, 480);
var target = cc.Sprite.create("resources/doge.png"); /*child to clip*/
var mask = cc.Sprite.create("resources/doge-mask.png"); /*mask*/
var maskedFill = new cc.ClippingNode(mask);
maskedFill.setAlphaThreshold(0.9);
maskedFill.addChild(target);
maskedFill.setPosition(144, 224);
backgroundLayer.addChild(maskedFill,0);
this.addChild(backgroundLayer);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.