问题
How to use camera in a customized CCLayer ( cocos2d for Android ) , i.e. adding VideoView to CCLayer ?
The camera does not require photo taking feature; only showing the view is fine. Yes, I would like to use the camera on mobile phone.
I use the following codes to show up the camera:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
theActivity.startActivity(cameraIntent);
but the view overlaps everything and will crash after few seconds. The error is:
NullPointerException at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:680)
回答1:
Not sure how this is done in your strange cross-platform framework, but camera preview can be piped pretty easily to any surface view and you can overlay it with other interface objects (unless they are surface views). There are android SDK examples showing how to do this
来源:https://stackoverflow.com/questions/8239623/camera-as-background-in-a-customized-cclayer-cocos2d-for-android