配置方式建立請看上文。
if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. view->setDesignResolutionSize(480, 800);//加入這一句,目的就是為了適配螢幕 AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); }
LOCAL_SRC_FILES := helloworld/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/BulletLayer.cpp \ ../../Classes/ControlLayer.cpp \ ../../Classes/Enemy1Layer.cpp \ ../../Classes/Enemy2Layer.cpp \ ../../Classes/Enemy3Layer.cpp \ ../../Classes/GameLayer.cpp \ ../../Classes/GameScene.cpp \ ../../Classes/PlaneLayer.cpp \ ../../Classes/WelcomeLayer.cpp \ ../../Classes/WelcomeScene.cpp \ ../../Classes/Enemy1Sprite.cpp \ ../../Classes/Enemy2Sprite.cpp \ ../../Classes/Enemy3Sprite.cpp \ ../../Classes/UFOLayer.cpp \ ../../Classes/GameOverLayer.cpp \ ../../Classes/GameOverScene.cpp \ ../../Classes/MutiBulletsLayer.cpp
public class JackyAirplane extends Cocos2dxActivity
public class Cocos2dxActivity extends Activity
Runnable runnable=new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubIntent intent = new Intent(LoadActivity.this, JackyAirplane.class);LoadActivity.this.startActivity(intent);//切換ActivityLoadActivity.this.finish();}};
public class JackyAirplane extends Cocos2dxActivity{...public static AdView adView; // 第3方廣告}
public static void showAD() { new Thread(new Runnable(){ @Override public void run() { adView.setVisibility( adView.VISIBLE ); } }).start();}
#include <jni/JniHelper.h>JniMethodInfo minfo; jobject jobj; bool b = JniHelper::getStaticMethodInfo(minfo, "com/jacky/jackyAirplane/JackyAirplane", //類路徑"showAD", //靜態方法名 "()V"); //括弧裡的是參數,後面的是返回值if(b)jobj = minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID); else;//列印錯誤...