显示礼物
来源:互联网 发布:c语言temp怎么交换位置 编辑:程序博客网 时间:2024/04/29 12:55
直播技术之使用cocos2dx显示礼物
1.需要使用到cocos2dx显示礼物则需要继承Cocos2dxActivity
首次先Cocos2dxActivity->onCreate()->init()
public void init() { // FrameLayout ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mFrameLayout = new FrameLayout(this); mFrameLayout.setLayoutParams(framelayout_params); // Cocos2dxEditText layout //ViewGroup.LayoutParams edittext_layout_params = // new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, // ViewGroup.LayoutParams.WRAP_CONTENT); //Cocos2dxEditText edittext = new Cocos2dxEditText(this); //edittext.setLayoutParams(edittext_layout_params); // ...add to FrameLayout //mFrameLayout.addView(edittext); // Cocos2dxGLSurfaceView this.mGLSurfaceView = this.onCreateView(); // ...add to FrameLayout mFrameLayout.addView(this.mGLSurfaceView); // Switch to supported OpenGL (ARGB888) mode on emulator if (isAndroidEmulator()) this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer()); //this.mGLSurfaceView.setCocos2dxEditText(edittext); // Set framelayout as the content view setContentView(mFrameLayout); }
其实Cocos2dxActivity已经给我我们提示,需要将我们自定义的布局按照怎样的顺序添加到ContentView中(10-18行);
abstract public View createCustomView();mFrameLayout.addView(createCustomView(), new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
所以只用在createCustomView()中实现自己的布局就可以。
2.使用自定义GLSurfaceView与GLSurfaceView.Renderer播放视频
render = new SurfaceView.Renderer(context); render.setGlSurfaceView(this); setEGLContextClientVersion(2); // 设置opengl es2 版本 this.setEGLConfigChooser(8, 8, 8, 8, 16, 0); this.getHolder().setFormat(PixelFormat.TRANSLUCENT); setRenderer(render); // 设置渲染 setRenderMode(RENDERMODE_WHEN_DIRTY); // 需要时渲 setZOrderOnTop(false);//重点,小心坑;在Cocos2dxActivity->onCreateView()->glSurfaceView.setZOrderOnTop(true);所以这里设置强制为false,是自定义GLSurfaceView在动画的下面 //Cocos2dxActivity->onCreateView() public Cocos2dxGLSurfaceView onCreateView() { Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); //this line is need on some device if we specify an alpha bits if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); glSurfaceView.setZOrderOnTop(true);// Cocos2dxEGLConfigChooser chooser = new Cocos2dxEGLConfigChooser(this.mGLContextAttrs); glSurfaceView.setEGLConfigChooser(chooser); return glSurfaceView; }
0 0
- 显示礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 礼物
- 情人节礼物方案!LED显示摇棒全套方案及源程序(zz)
- 收到礼物
- 许巍 "礼物"
- 一件礼物
- 还是礼物
- 圣诞礼物
- 礼物一件件
- Dubbo消费端java.lang.NoClassDefFoundError错误的排查
- 【HDU5895【公式转化 矩阵快速幂 欧拉定义】Mathematician QSC 递推数列前n平方项和 (转)
- NOIP专题复习——专题二:动态规划基础
- gdb调试线程
- 如何解压deb 包;
- 显示礼物
- 16.10.29 提高C组总结
- 正则化方法:防止过拟合,提高泛化能力
- python Anaconda2安装OpenCV2
- sql与hql的区别
- CCF 送货
- 程序改错
- 冒泡排序
- Linux学习之 嵌入式数据库