How to use camera to make split screen or small map?

How to use camera to make split screen or small map?

Hi all Cocos Creator users!
I’ve just upgraded from 1.9.3 to 2.0.9 and found out many changes with camera.

As mentioned here:

Multi-camera support allows you to easily implement advanced customization effects, such as the two-player split screen effect, or the creation of a small scene map

So I wonder how to implement the split screen or a small map using camera?
I’ve searched the docs as well as forum with no luck.

As I know the camera will flush all it captures directly to entire viewport screen. How do we restrict the render area of a camera, so, smthing like output of camera 1 renders only to left half and camera 2 to right half of screen?

Thanks in advance for any suggestion!
And many thanks to @slackmoehrle if you could help.

Lets ask @Big_Bear for how to use this. My initial thought is more than one camera, but I’m not sure if that is correct for Creator. In Cocos2d-x I would just use multiple cameras.

Refenece this minimap demo:


Thanks @Big_Bear
I’ve tested your example code and found out that it calls to renderTexture every frame
Is that performance wise? Could it be more efficient if I clone another instance of the entire map-node to put into the mini-map and just update the position changes from real-map?

Tested minimap demo of @Big_Bear with Cocos 2.0.9 on laptop core i5 Kabylake + NVIDIA Geforce gtx 1050 and result went like…

The simulator ran well for 1 minute and caused the whole laptop to hang for another 1 minute before I can close the simulator.

this demo is just an example, it shows how to implement the minimap with camera, but I did not think about performance.

you can optimized it, e.g every frame new a SpriteFrame is a bad realization, you can just replace with using the “setTexture”

Hi @Big_Bear
I’ve tried to optimize using setTexture() as you suggested but the frame-time kept showing 30-35 and fps dropped to 10-20 fps.
I think renderTexture() should be the culprit. Maybe something different between Creator & 2dx.
Anyway. you’re the one who wrote the core functions, your suggestion should be the best advice.

I redraw all the necessary parts of real map inside mini map. And performance is not bad. Honestly.

how would you use multiple cameras to make a split screen?