-
Creator 版本: <2.4.5>
-
目标平台: <Chrome模拟器>
cc.loader.loadRes(“hall/roomList”,cc.SpriteAtlas,function(err, res:cc.SpriteAtlas){
let renderTexture = new cc.RenderTexture(); renderTexture.initWithSize(664,936); // cc.renderer.device.setFrameBuffer(renderTexture._framebuffer); (<any>renderTexture).drawTextureAt(res.getSpriteFrame("chip").getTexture(),0,0); let node = new cc.Node(); node.addComponent(cc.Sprite); let frame = new cc.SpriteFrame(); frame.setTexture(renderTexture); //node.getComponent(cc.Sprite).spriteFrame = res.getSpriteFrame("chip"); node.getComponent(cc.Sprite).spriteFrame = frame; node.parent = this.node; }.bind(this));
node.getComponent(cc.Sprite).spriteFrame = res.getSpriteFrame(“chip”);这样能正常显示图片
let frame = new cc.SpriteFrame();
frame.setTexture(renderTexture);
node.getComponent(cc.Sprite).spriteFrame = frame;
这样就报错。
chrome模拟器是报错
[.WebGL-0x7fa9f02afa00]GL ERROR :GL_INVALID_VALUE : glTexSubImage2D: bad dimensions.
安卓真机报错
- location : (see stack)
- msg : Uncaught TypeError: Cannot read property ‘length’ of null
- detail :
[0]_p.updateSubImage@jsb-adapter/jsb-builtin.js:7270
[1]drawTextureAt@src/cocos2d-jsb.js:18439
请问我是哪里用错了吗》?弄了几个小时一直没弄出来,奇怪了。我是想用drawTextureAt把两张图画在一个精灵帧里面,求助!!谢谢