相机作为自定义 CCLayer 的背景(cocos2d for Android)?
如何在自定义的CCLayer(Android 版cocos2d)中使用摄像头,即将VideoView 添加到CCLayer 中?
相机不需要拍照功能;只显示视图就可以了。是的,我想使用手机上的相机。
我使用以下代码来显示相机:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
theActivity.startActivity(cameraIntent);
但视图与所有内容重叠,几秒钟后就会崩溃。错误是:
NullPointerException at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:680)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是如何在奇怪的跨平台框架中完成的,但是相机预览可以很容易地通过管道传输到任何表面视图,并且您可以将其与其他界面覆盖
对象(除非它们是表面视图)。有 android SDK 示例展示了如何做到这一点
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