Update HelloLua

This commit is contained in:
folecr 2013-08-05 16:34:07 -07:00
parent bf6b57fe19
commit 07917429a0
6 changed files with 15 additions and 94 deletions

View File

@ -4,17 +4,22 @@
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9"/> <uses-sdk android:minSdkVersion="9"/>
<uses-feature android:glEsVersion="0x00020000" /> <uses-feature android:glEsVersion="0x00020000" />
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/icon"> android:icon="@drawable/icon">
<activity android:name=".HelloLua" <activity android:name="android.app.NativeActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation"> android:configChanges="orientation|screenSize|smallestScreenSize">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="hellolua" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

View File

@ -15,6 +15,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@ -22,3 +23,4 @@ $(call import-module,cocos2dx)
$(call import-module,CocosDenshion/android) $(call import-module,CocosDenshion/android)
$(call import-module,scripting/lua/proj.android) $(call import-module,scripting/lua/proj.android)
$(call import-module,extensions) $(call import-module,extensions)
$(call import-module,cocos2dx/platform/android)

View File

@ -9,35 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
extern "C" void cocos_android_app_init (void) {
{ LOGD("cocos_android_app_init");
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
return JNI_VERSION_1_4;
}
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!Director::getInstance()->getOpenGLView())
{
EGLView *view = EGLView::getInstance();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
else
{
GL::invalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
DrawPrimitives::init();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
}
} }

View File

@ -8,6 +8,6 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-10 target=android-13
android.library.reference.1=../../../../cocos2dx/platform/android/java android.library.reference.1=../../../../cocos2dx/platform/android/java

View File

@ -0,0 +1 @@
No Java files

View File

@ -1,59 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.hellolua;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
public class HelloLua extends Cocos2dxActivity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
public Cocos2dxGLSurfaceView onCreateGLSurfaceView() {
return new LuaGLSurfaceView(this);
}
static {
System.loadLibrary("hellolua");
}
}
class LuaGLSurfaceView extends Cocos2dxGLSurfaceView{
public LuaGLSurfaceView(Context context){
super(context);
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
// exit program when key back is entered
if (keyCode == KeyEvent.KEYCODE_BACK) {
android.os.Process.killProcess(android.os.Process.myPid());
}
return super.onKeyDown(keyCode, event);
}
}