Home > other >  Cocos2dx questions about RenderTexture
Cocos2dx questions about RenderTexture

Time:09-28

In the use of RenderTexture interception of any size, location and size have a few problems, hope you can get help,
Code description:
Board_node: Node Node, its size is 720 * 810
Also just want to intercept board_node node rendering layer,

 
Var rend=new cc. RenderTexture (720, 810)
Rend. SetVirtualViewport (cc) p (0, 0), the new cc. The rect (0,0,720,810), the new cc. The rect,0,720,810 (0))

Rend the begin ()
Board_node. Visit ()
Rend the end ()


The above code, rend the size is 720 * 810, but only half board_node interception effect, when it is changed to 720 * 1200 intercepts all, don't understand, when the size is 720 * 810, why can't complete the interception,
Now as shown in figure, is anyone know why?
The effect of 720 * 810



The effect of 720 * 1200


CodePudding user response:

If I don't want to wrong, you board the position of the node is not based on the rect (0, 0, 720, 810) centered, mostly centered in the screen first, and then follow the call the code to a frame buffer, so the cache part of the texture will be truncated and part of the unmodified (default is cc. C4b,0,0,0 (0))
Other way, you imagine yourself only 720 x 810 screen resolution, it is good to put the board in the middle, concrete realization himself,

And you the second sentence doesn't make any sense, actually has a constructor these parameters

  • Related