1. HelloCpp是一个Activity,继承Cocos2dActivityx首先会执行静态代码块,加载libhellocpp.so库,然后就是执行onCreate方法,这里调用了父类的onCreate方法。我们看看Cocos2dxActivity的onCreate方法,该类在cocos2dx的库工程libcocos2dx中:
Cocos2dxHandler处理Dialog的消息,Cocos2dxHelper是帮助类,在init方法中,是为Activity绑定View Hierarchy,View Hierarchy的根View是个FrameLayout,FrameLayout又包含一个EditText和一个GLSurfaceView,这个GLSurfaceView就是cocos引擎用来绘制游戏画面的关键View。Cocos2dxActivity的onCreateView方法:
是新建一个Cocos2dxGLSurfaceView,Cocos2dxGLSurfaceView又继承于GLSurfaceView。我们都知道GLSurfaceView的核心就是Renderer,初始化时会调用Renderer的onSurfaceCreated方法,每一帧的绘制是通过调用Renderer的onDrawFrame方法。Cocos2dxGLSurfaceView的Renderer是一个Cocos2dxRenderer对象,Cocos2dxRenderer对象的onSurfaceCreated方法:
nativeinit方法在main.cpp中,