mirror of https://github.com/axmolengine/axmol.git
issue #1425: add android proj on TestLua
This commit is contained in:
parent
998cb276ba
commit
f67b513d08
|
@ -1,186 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "kazmath/ray2.h"
|
||||
|
||||
void kmRay2Fill(kmRay2* ray, kmScalar px, kmScalar py, kmScalar vx, kmScalar vy) {
|
||||
ray->start.x = px;
|
||||
ray->start.y = py;
|
||||
ray->dir.x = vx;
|
||||
ray->dir.y = vy;
|
||||
}
|
||||
|
||||
kmBool kmRay2IntersectLineSegment(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, kmVec2* intersection) {
|
||||
|
||||
float x1 = ray->start.x;
|
||||
float y1 = ray->start.y;
|
||||
float x2 = ray->start.x + ray->dir.x;
|
||||
float y2 = ray->start.y + ray->dir.y;
|
||||
float x3 = p1->x;
|
||||
float y3 = p1->y;
|
||||
float x4 = p2->x;
|
||||
float y4 = p2->y;
|
||||
|
||||
float denom = (y4 -y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
||||
float ua, x, y;
|
||||
//If denom is zero, the lines are parallel
|
||||
if(denom > -kmEpsilon && denom < kmEpsilon) {
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom;
|
||||
// float ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom;
|
||||
|
||||
x = x1 + ua * (x2 - x1);
|
||||
y = y1 + ua * (y2 - y1);
|
||||
|
||||
if(x < kmMin(p1->x, p2->x) - kmEpsilon ||
|
||||
x > kmMax(p1->x, p2->x) + kmEpsilon ||
|
||||
y < kmMin(p1->y, p2->y) - kmEpsilon ||
|
||||
y > kmMax(p1->y, p2->y) + kmEpsilon) {
|
||||
//Outside of line
|
||||
//printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1->x, p1->y, p2->x, p2->y);
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
if(x < kmMin(x1, x2) - kmEpsilon ||
|
||||
x > kmMax(x1, x2) + kmEpsilon ||
|
||||
y < kmMin(y1, y2) - kmEpsilon ||
|
||||
y > kmMax(y1, y2) + kmEpsilon) {
|
||||
//printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2);
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
intersection->x = x;
|
||||
intersection->y = y;
|
||||
|
||||
return KM_TRUE;
|
||||
|
||||
|
||||
/*
|
||||
kmScalar A1, B1, C1;
|
||||
kmScalar A2, B2, C2;
|
||||
|
||||
A1 = ray->dir.y;
|
||||
B1 = ray->dir.x;
|
||||
C1 = A1 * ray->start.x + B1 * ray->start.y;
|
||||
|
||||
A2 = p2->y - p1->y;
|
||||
B2 = p2->x - p1->x;
|
||||
C2 = A2 * p1->x + B2 * p1->y;
|
||||
|
||||
double det = (A1 * B2) - (A2 * B1);
|
||||
if(det == 0) {
|
||||
printf("Parallel\n");
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
double x = (B2*C1 - B1*C2) / det;
|
||||
double y = (A1*C2 - A2*C1) / det;
|
||||
|
||||
if(x < min(p1->x, p2->x) - kmEpsilon ||
|
||||
x > max(p1->x, p2->x) + kmEpsilon ||
|
||||
y < min(p1->y, p2->y) - kmEpsilon ||
|
||||
y > max(p1->y, p2->y) + kmEpsilon) {
|
||||
//Outside of line
|
||||
printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1->x, p1->y, p2->x, p2->y);
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
kmScalar x1 = ray->start.x;
|
||||
kmScalar x2 = ray->start.x + ray->dir.x;
|
||||
|
||||
kmScalar y1 = ray->start.y;
|
||||
kmScalar y2 = ray->start.y + ray->dir.y;
|
||||
|
||||
if(x < min(x1, x2) - kmEpsilon ||
|
||||
x > max(x1, x2) + kmEpsilon ||
|
||||
y < min(y1, y2) - kmEpsilon ||
|
||||
y > max(y1, y2) + kmEpsilon) {
|
||||
printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2);
|
||||
return KM_FALSE;
|
||||
}
|
||||
|
||||
intersection->x = x;
|
||||
intersection->y = y;
|
||||
|
||||
return KM_TRUE;*/
|
||||
}
|
||||
|
||||
void calculate_line_normal(kmVec2 p1, kmVec2 p2, kmVec2* normal_out) {
|
||||
kmVec2 tmp;
|
||||
kmVec2Subtract(&tmp, &p2, &p1); //Get direction vector
|
||||
|
||||
normal_out->x = -tmp.y;
|
||||
normal_out->y = tmp.x;
|
||||
kmVec2Normalize(normal_out, normal_out);
|
||||
|
||||
//TODO: should check that the normal is pointing out of the triangle
|
||||
}
|
||||
|
||||
kmBool kmRay2IntersectTriangle(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, const kmVec2* p3, kmVec2* intersection, kmVec2* normal_out) {
|
||||
kmVec2 intersect;
|
||||
kmVec2 final_intersect = {.x = 0, .y = 0}, normal = {.x = 0, .y = 0}; // Silencing LLVM SA
|
||||
kmScalar distance = 10000.0f;
|
||||
kmBool intersected = KM_FALSE;
|
||||
|
||||
if(kmRay2IntersectLineSegment(ray, p1, p2, &intersect)) {
|
||||
kmVec2 tmp;
|
||||
kmScalar this_distance;
|
||||
|
||||
intersected = KM_TRUE;
|
||||
this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start));
|
||||
if(this_distance < distance) {
|
||||
final_intersect.x = intersect.x;
|
||||
final_intersect.y = intersect.y;
|
||||
distance = this_distance;
|
||||
|
||||
calculate_line_normal(*p1, *p2, &normal);
|
||||
}
|
||||
}
|
||||
|
||||
if(kmRay2IntersectLineSegment(ray, p2, p3, &intersect)) {
|
||||
kmVec2 tmp;
|
||||
kmScalar this_distance;
|
||||
intersected = KM_TRUE;
|
||||
|
||||
this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start));
|
||||
if(this_distance < distance) {
|
||||
final_intersect.x = intersect.x;
|
||||
final_intersect.y = intersect.y;
|
||||
distance = this_distance;
|
||||
|
||||
calculate_line_normal(*p2, *p3, &normal);
|
||||
}
|
||||
}
|
||||
|
||||
if(kmRay2IntersectLineSegment(ray, p3, p1, &intersect)) {
|
||||
kmVec2 tmp;
|
||||
kmScalar this_distance;
|
||||
intersected = KM_TRUE;
|
||||
|
||||
this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start));
|
||||
if(this_distance < distance) {
|
||||
final_intersect.x = intersect.x;
|
||||
final_intersect.y = intersect.y;
|
||||
//distance = this_distance;
|
||||
|
||||
calculate_line_normal(*p3, *p1, &normal);
|
||||
}
|
||||
}
|
||||
|
||||
if(intersected) {
|
||||
intersection->x = final_intersect.x;
|
||||
intersection->y = final_intersect.y;
|
||||
if(normal_out) {
|
||||
normal_out->x = normal.x;
|
||||
normal_out->y = normal.y;
|
||||
}
|
||||
}
|
||||
|
||||
return intersected;
|
||||
}
|
||||
|
||||
kmBool kmRay2IntersectCircle(const kmRay2* ray, const kmVec2 centre, const kmScalar radius, kmVec2* intersection) {
|
||||
assert(0 && "Not implemented");
|
||||
return 0;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
require "helper"
|
||||
require "luaScript/helper"
|
||||
|
||||
|
||||
Action_Table =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "ActionsTest/ActionsName"
|
||||
require "luaScript/ActionsTest/ActionsName"
|
||||
|
||||
|
||||
local ActionIdx = -1
|
||||
|
@ -998,17 +998,17 @@ end
|
|||
--------------------------------------
|
||||
local pausedTargets = nil
|
||||
|
||||
local function ActionPause(dt)
|
||||
local function ActionPause()
|
||||
cclog("Pausing")
|
||||
local director = CCDirector:sharedDirector()
|
||||
pausedTargets = director:getActionManager():pauseAllRunningActions()
|
||||
end
|
||||
|
||||
local function ActionResume(dt)
|
||||
local function ActionResume()
|
||||
cclog("Resuming")
|
||||
local director = CCDirector:sharedDirector()
|
||||
if pausedTargets ~= nil then
|
||||
-- director:getActionManager():resumeTargets(pausedTargets)
|
||||
director:getActionManager():resumeTargets(pausedTargets)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1021,9 +1021,8 @@ local function PauseResumeActions()
|
|||
tamara:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360)))
|
||||
kathia:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360)))
|
||||
|
||||
local scheduler = CCDirector:sharedDirector():getScheduler()
|
||||
--scheduler:scheduleScriptFunc(ActionPause, 3, false)
|
||||
--scheduler:scheduleScriptFunc(ActionResume, 5, false)
|
||||
layer:scheduleScriptFunc(ActionPause, 3, false)
|
||||
layer:scheduleScriptFunc(ActionResume, 5, false)
|
||||
|
||||
titleLabel:setString("PauseResumeActions")
|
||||
subtitleLabel:setString("All actions pause at 3s and resume at 5s")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "EffectsTest/EffectsName"
|
||||
require "luaScript/EffectsTest/EffectsName"
|
||||
|
||||
|
||||
local ActionIdx = 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "helper"
|
||||
require "luaScript/helper"
|
||||
|
||||
|
||||
Particle_Table =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "../helper"
|
||||
require "luaScript/helper"
|
||||
|
||||
Transition_Table =
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require "TransitionsTest/TransitionsName"
|
||||
require "luaScript/TransitionsTest/TransitionsName"
|
||||
|
||||
|
||||
local SceneIdx = 0
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
collectgarbage("setpause", 100)
|
||||
collectgarbage("setstepmul", 5000)
|
||||
|
||||
require "mainMenu"
|
||||
require "luaScript/mainMenu"
|
||||
----------------
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require "tests"
|
||||
require "helper"
|
||||
require "testResource"
|
||||
require "luaScript/tests"
|
||||
require "luaScript/helper"
|
||||
require "luaScript/testResource"
|
||||
------------------------
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require "helper"
|
||||
require "luaScript/helper"
|
||||
|
||||
require "ActionsTest/ActionsTest"
|
||||
require "TransitionsTest/TransitionsTest"
|
||||
require "ActionsProgressTest/ActionsProgressTest"
|
||||
require "EffectsTest/EffectsTest"
|
||||
require "ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "RotateWorldTest/RotateWorldTest"
|
||||
require "luaScript/ActionsTest/ActionsTest"
|
||||
require "luaScript/TransitionsTest/TransitionsTest"
|
||||
require "luaScript/ActionsProgressTest/ActionsProgressTest"
|
||||
require "luaScript/EffectsTest/EffectsTest"
|
||||
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "luaScript/RotateWorldTest/RotateWorldTest"
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="src_common"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>TestLua</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>src_common</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/cocos2dx/platform/android/java/src_common</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.cocos2dx.testlua"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8"/>
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:debuggable="true" android:icon="@drawable/icon">
|
||||
|
||||
<activity android:name=".TestLua"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:configChanges="orientation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
<supports-screens android:largeScreens="true"
|
||||
android:smallScreens="true"
|
||||
android:anyDensity="true"
|
||||
android:normalScreens="true"/>
|
||||
</manifest>
|
|
@ -0,0 +1,17 @@
|
|||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="TestLua" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -0,0 +1,76 @@
|
|||
APPNAME="HelloLua"
|
||||
|
||||
# options
|
||||
|
||||
buildexternalsfromsource=
|
||||
|
||||
usage(){
|
||||
cat << EOF
|
||||
usage: $0 [options]
|
||||
|
||||
Build C/C++ code for $APPNAME using Android NDK
|
||||
|
||||
OPTIONS:
|
||||
-s Build externals from source
|
||||
-h this help
|
||||
EOF
|
||||
}
|
||||
|
||||
while getopts "sh" OPTION; do
|
||||
case "$OPTION" in
|
||||
s)
|
||||
buildexternalsfromsource=1
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# paths
|
||||
|
||||
if [ -z "${NDK_ROOT+aaa}" ];then
|
||||
echo "please define NDK_ROOT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
# ... use paths relative to current directory
|
||||
COCOS2DX_ROOT="$DIR/../../.."
|
||||
APP_ROOT="$DIR/.."
|
||||
APP_ANDROID_ROOT="$DIR"
|
||||
|
||||
echo "NDK_ROOT = $NDK_ROOT"
|
||||
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||
echo "APP_ROOT = $APP_ROOT"
|
||||
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
|
||||
|
||||
# make sure assets is exist
|
||||
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
|
||||
rm -rf "$APP_ANDROID_ROOT"/assets
|
||||
fi
|
||||
|
||||
mkdir "$APP_ANDROID_ROOT"/assets
|
||||
|
||||
# copy resources
|
||||
for file in "$APP_ROOT"/Resources/*
|
||||
do
|
||||
if [ -d "$file" ]; then
|
||||
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
|
||||
fi
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
cp "$file" "$APP_ANDROID_ROOT"/assets
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$buildexternalsfromsource" ]]; then
|
||||
echo "Building external dependencies from source"
|
||||
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
||||
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
|
||||
else
|
||||
echo "Using prebuilt externals"
|
||||
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
|
||||
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
|
||||
fi
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,13 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-8
|
||||
|
||||
android.library.reference.1=../../../cocos2dx/platform/android/java
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">TestLua</string>
|
||||
</resources>
|
|
@ -0,0 +1,126 @@
|
|||
/****************************************************************************
|
||||
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.testlua;
|
||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||
import org.cocos2dx.lib.Cocos2dxEditText;
|
||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
||||
import org.cocos2dx.lib.Cocos2dxRenderer;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class TestLua extends Cocos2dxActivity{
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (detectOpenGLES20()) {
|
||||
// get the packageName,it's used to set the resource path
|
||||
String packageName = getApplication().getPackageName();
|
||||
super.setPackageName(packageName);
|
||||
|
||||
// FrameLayout
|
||||
ViewGroup.LayoutParams framelayout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.FILL_PARENT);
|
||||
FrameLayout framelayout = new FrameLayout(this);
|
||||
framelayout.setLayoutParams(framelayout_params);
|
||||
|
||||
// Cocos2dxEditText layout
|
||||
ViewGroup.LayoutParams edittext_layout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
Cocos2dxEditText edittext = new Cocos2dxEditText(this);
|
||||
edittext.setLayoutParams(edittext_layout_params);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(edittext);
|
||||
|
||||
// LuaGLSurfaceView
|
||||
mGLView = new LuaGLSurfaceView(this);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(mGLView);
|
||||
|
||||
mGLView.setEGLContextClientVersion(2);
|
||||
mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||
mGLView.setTextField(edittext);
|
||||
|
||||
// Set framelayout as the content view
|
||||
setContentView(framelayout);
|
||||
}
|
||||
else {
|
||||
Log.d("activity", "don't support gles2.0");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mGLView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mGLView.onResume();
|
||||
}
|
||||
|
||||
private boolean detectOpenGLES20()
|
||||
{
|
||||
ActivityManager am =
|
||||
(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ConfigurationInfo info = am.getDeviceConfigurationInfo();
|
||||
return (info.reqGlEsVersion >= 0x20000);
|
||||
}
|
||||
|
||||
private LuaGLSurfaceView mGLView;
|
||||
|
||||
|
||||
static {
|
||||
System.loadLibrary("testlua");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue