Cocos2d Android移植手记(二) - cocos2d Android包框架设计
jopen
13年前
<p>随着android平台的推广和android手机的大量推出,有人预言android将是一个嵌入式的统一平台。果真如此 吗?Apple,Microsoft, nokia不会坐视不管的,在想想unix各种混乱的版本,总让人忧心忡忡。不过有google这位大神做东,至少在短期内,android会很稳定,市 场会有一席之地。目前,网上很少有使用java开发的开源游戏引擎,大多数情况下都因为java的执行效率问题。不过,既然google官方提供了 opengles的支持,为什么不试下呢?至少程序员可以不担心硬件层的差异了。</p> <p>“万事开头难”,由于第一次研究游戏引擎,脑子里也是一头雾水,所以模仿cocos2d的结构,初步定义了部分包和类。欢迎大家多提意见。</p> <p>cocos2d android包框架图:</p> <p><a href="https://simg.open-open.com/show/6f11ead7a636dcc9242a15e25af06530.jpg" target="_blank"><img style="width:713px;height:259px;cursor:pointer;" title="package" alt="Cocos2d Android移植手记(二) - cocos2d Android包框架设计" src="https://simg.open-open.com/show/6f11ead7a636dcc9242a15e25af06530.jpg" /></a></p> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid: 包含程序的入口类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>main:派生自ListActivity的入口类,可以浏览tests包中的所有Activity。</td> </tr> <tr> <td><br /> </td> <td>R:android资源类</td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d: cocos2d中的常用高级类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>Cocos2d:保存cocos2d的基本信息,例如:当前的版本号,移植的版本号等</td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.action: cocos2d中用于定义对象行为的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>Action:所有行为的基类</td> </tr> <tr> <td><br /> </td> <td>Animate</td> </tr> <tr> <td><br /> </td> <td>BezierBy</td> </tr> <tr> <td><br /> </td> <td>Blink</td> </tr> <tr> <td><br /> </td> <td>CameraAction</td> </tr> <tr> <td><br /> </td> <td>DelayTime</td> </tr> <tr> <td><br /> </td> <td>EaseAction</td> </tr> <tr> <td><br /> </td> <td>EaseExponentialIn</td> </tr> <tr> <td><br /> </td> <td>EaseExponentialOut</td> </tr> <tr> <td><br /> </td> <td>EaseIn</td> </tr> <tr> <td><br /> </td> <td>EaseInOut</td> </tr> <tr> <td><br /> </td> <td>EaseOut</td> </tr> <tr> <td><br /> </td> <td>EaseRateAction</td> </tr> <tr> <td><br /> </td> <td>EaseSineIn</td> </tr> <tr> <td><br /> </td> <td>EaseSineInOut</td> </tr> <tr> <td><br /> </td> <td>EaseSineOut</td> </tr> <tr> <td><br /> </td> <td>FadeIn</td> </tr> <tr> <td><br /> </td> <td>FadeOut</td> </tr> <tr> <td><br /> </td> <td>FadeTo</td> </tr> <tr> <td><br /> </td> <td>FiniteTimeAction</td> </tr> <tr> <td><br /> </td> <td>IntervalAction</td> </tr> <tr> <td><br /> </td> <td>JumpBy</td> </tr> <tr> <td><br /> </td> <td>JumpTo</td> </tr> <tr> <td><br /> </td> <td>MoveBy</td> </tr> <tr> <td><br /> </td> <td>MoveTo</td> </tr> <tr> <td><br /> </td> <td>OrbitCamera</td> </tr> <tr> <td><br /> </td> <td>Repeat</td> </tr> <tr> <td><br /> </td> <td>RepeatForever</td> </tr> <tr> <td><br /> </td> <td>ReverseTime</td> </tr> <tr> <td><br /> </td> <td>RotateBy</td> </tr> <tr> <td><br /> </td> <td>RotateTo</td> </tr> <tr> <td><br /> </td> <td>ScaleBy</td> </tr> <tr> <td><br /> </td> <td>ScaleTo</td> </tr> <tr> <td><br /> </td> <td>Sequence</td> </tr> <tr> <td><br /> </td> <td>Spawn</td> </tr> <tr> <td><br /> </td> <td>Speed</td> </tr> <tr> <td><br /> </td> <td>TintTo</td> </tr> <tr> <td><br /> </td> <td>TintBy</td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.cocoslive: cocos2d用于网络通讯的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.effects: cocos2d中各种特效类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.experimental: cocos2d中实验阶段的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.external: cocos2d中使用到的其他第三方的库和类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.image: cocos2d中用于处理图片的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.nodes:cocos2d中可用于渲染的数据类型</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>CocosNode:所有可渲染对象的基类</td> </tr> <tr> <td><br /> </td> <td>Layer:层</td> </tr> <tr> <td><br /> </td> <td>Scene:场景</td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.opengles:cocos2d中支持opengles的视图类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>GLSurfaceView:用于绘制Opengl ES的视图类</td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.particles: cocos2d中的用于粒子效果的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td><br /> </td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.renderer:cocos2d中的渲染类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>CubeRenderer:渲染cube对象的render</td> </tr> <tr> <td><br /> </td> <td>Director</td> </tr> <tr> <td><br /> </td> <td>FastDirector</td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.tests:cocos2d中用于测试的类</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>OpenglesTest:测试OpenglES基本框架的类</td> </tr> </tbody> </table> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>com.moandroid.cocos2d.types: cocos2d中使用的基本数据类型</td> </tr> <tr> <td>Class:</td> <td><br /> </td> </tr> <tr> <td><br /> </td> <td>ccColorB:颜色值(字节表示)</td> </tr> <tr> <td><br /> </td> <td>ccColorF:颜色值(浮点数表示)</td> </tr> <tr> <td><br /> </td> <td>ccGridSize:网格大小</td> </tr> <tr> <td><br /> </td> <td>ccPointSprite:点精灵</td> </tr> <tr> <td><br /> </td> <td>ccQuad2:2维变换矩阵</td> </tr> <tr> <td><br /> </td> <td>ccQuad3:3维变换矩阵</td> </tr> <tr> <td><br /> </td> <td>ccRGBB:RGB值(字节表示)</td> </tr> <tr> <td><br /> </td> <td>ccTime:时间类</td> </tr> <tr> <td><br /> </td> <td>ccVertex3D:顶点</td> </tr> </tbody> </table> <p>目前工程只完成了部分类的实现,所以类结构可能会不断变化,我会在以后持续更新上面的表格。</p> <p>文章出处:<a href="/misc/goto?guid=4959500825353627810" rel="nofollow">http://www.moandroid.com/?p=729</a></p>