2
CCSprite texture1 = CCSprite.sprite("menu_background.png");
CCRenderTexture layerRenderTexture = CCRenderTexture.renderTexture(width, height);
layerRenderTexture.begin();
texture1.visit(CCDirector.gl);
layerRenderTexture.end();
this.addChild(layerRenderTexture);

I haven't seen any CCRenderTexture example on Internet. When I try to use it as above, I expected to see a nice background. Instead I see black :)

What am I doing wrong? Thanks for your help.

mig
  • 21
  • 3

1 Answers1

2

I haven't seen any CCRenderTexture example on Internet.

I think you may have been looking on the wrong Internet? :)

Check out my article and Ray's article. Both come out on top when you google for CCRenderTexture. They use cocos2d-iphone, but the same principles apply.

In your particular case I don't see you adding the layerRenderTexture as child to the scene or another node. That would explain why you're not getting any results.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Firstly thanks for your reply:) I have developed and finished my iPhone project already. Now I am trying to implement it on Android. At the links you sent me, it is written about Cocos2d on Iphone not Android. By the way, of course I have added layerRenderTexture as child to the layer. I know the principle is same as iPhone, but I can not implement this on Android. – mig May 15 '12 at 07:36
  • Long shot, maybe you're experiencing this issue? http://code.google.com/p/cocos2d-android-1/issues/detail?id=71 – CodeSmile May 15 '12 at 09:19
  • do you have any solution for that? – mig May 15 '12 at 10:52
  • "I think you may have been looking on the wrong Internet?" :) Did you find anything in the correct Internet? :) – mig May 15 '12 at 13:50