Merge remote branch 'upstream/master'

This commit is contained in:
Leon 2011-10-20 18:34:10 +08:00
commit 5c4a3c3fda
40 changed files with 210 additions and 152 deletions

3
.gitignore vendored
View File

@ -37,6 +37,9 @@ assets/
.project
.cproject
# Ignore files build by linux
*.o
# Ignore files build by airplay
build_*_xcode/

22
AUTHORS
View File

@ -8,8 +8,25 @@ Core Developers:
WenSheng Yang
Bin Zhang
RongHong Huang
JianHua Chen
Developers:
HuaXu Cai
author of linux port
ciaranj
add a build file that correctly generates LuaCocos2d.cpp
add a lua template
add particle systems to lua bindings
use ant to generate LuaCocos2d.cpp and lua projects
moadib
add ability of simulating android enter/resume background on win32
add ability of simulating android back/menu key on win32
reflog
add a helper method to draw filled polygons
ZhuoShi Shun
contribute the lua binding of CocosDenshion
@ -30,10 +47,7 @@ Developers:
Dumganhar
author of Bada port
ciaranj
add a build file that correctly generates LuaCocos2d.cpp
add a lua template
Cocos2d-x can not grow so fast without the active community.
Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups!

View File

@ -1,3 +1,63 @@
cocos2d-1.0.1-x-0.9.2 @ Oct.20,2011
[linux]
Feature #728 Linux port is born! http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_run_HelloWorld_and_tests_on_linux
[all platforms]
Feature #672 Implements copyWithZone() for CCShow & CCHide
Feature #676 add more languages into CCApplication::getCurrentLanguage()
Feature #678 add private constructor for CCArray
Feature #684 add test case for CCApplication::getCurrentLanguage()
Feature #685 add test case in LabelTest to display Chinese charactors
Bug #675 Fix memory leak in CCLayer when using accelerometer
Bug #686 CCTMXLayer::appendTileForGID() not setting Z index tag causes the first screen of tiles to be re-created
Bug #689 CCRect should assert the width and height is positive
Bug #698 CCSprite::init() is excited twice in all CCSprite's static methods
Bug #700 CC_SWAP32 marco has a typo with leads to error swap result
Bug #701 CCZHeader.version should be unsigned short
Bug #715 CCFadeOut causes a crash when applied to CCMenuItem and m_pSelectedImage is NULL
Bug #718 fix a typo in method CCMenu::alignItemsInRows
Bug #749 CCSpriteTest crashes at the test case SpriteNilTexture
Bug #750 CCTextureCache::textureForKey() can't find textures added by function addUIImage()
Refactor #677 Pass arguments by reference instead of pointer if possible
Refactor #703 Refactor Accelerometer. Because it only sends data to one delegate, so it needs only one setDelegate()
Document #692 Describe the usage of view orientation http://www.cocos2d-x.org/projects/cocos2d-x/wiki/About_device_orientation
[android]
Feature #670 Pause & resume effect playing when activity is paused & resumed
Feature #687 Implement preloadBackgroundMusic to android
Feature #688 Support reading resources not only from apk
Feature #726 use external storage on android
Feature #746 add a helper method to draw filled polygons
Bug #683 getPackagenameJNI() and getCurrentLanguageJNI() mustn't return invalid pointer
Bug #696 Some android devices may crash at CCRenderTexture::end(bool)
Bug #719 CocosDenshionTest crashes when start the test case on android
Bug #714 CCLabelTTF has different visual result between Android & Windows
Bug #727 Memory leak of NewStringUTF
Bug #736 Remove android:installLocation in AndroidManifest.xml
Bug #743 nativeInit is called with wrong screen size when running on device with software android buttons
Bug #744 CCUserDefault crashes in v0.9.1
Bug #755 Multi-touch causes crash on sum sung devices
[ios]
Bug #660 CCLabelBMFont image error in retina display
Bug #693 CCLabelTTF can not break line by '\n' on iOS
Bug #716 subbing & adding volume of sound effects don't change volume little by little on iOS
Bug #738 Passing CCSize(width,0) to CCLabelTTF causes the label invisible
Bug #753 visual orientation is wrong on ios5 simulator
Bug #754 Missing png file for CCLabelAtlas cause crashes on iOS 4.3.3 & 5.0
[win32]
Feature #731 add ability of simulating android back/menu key on win32
Feature #735 add ability of simulating android enter/resume background on win32. Shift+F1=android Back, Shift+F2 =android Menu
Feature #745 export CCTime to all
Bug #747 Win32 templates should put all resources into "Resources" folder
Bug #748 build error in win32 release version
[wophone]
Bug #702 tests crash at the start on wophone devices
[lua]
Feature #704 Print error descriptions ad pop error code in CCLuaScriptModule::executeString & CCLuaScriptModule::executeScriptFile
Feature #707 Support 'require' for lua on android
Feature #732 Add particle systems to lua bindings
Feature #733 Use ant to generate a lua project, refer to http://www.cocos2d-x.org/boards/11/topics/3957
Feature #734 Use ant to generate LuaCocos2d.cpp
cocos2d-1.0.1-x-0.9.1 @ Aug.17,2011
[all platforms]
Feature #347 Support custom TTF fonts

View File

@ -40,16 +40,6 @@ public class HelloLua extends Cocos2dxActivity{
mGLView = new LuaGLSurfaceView(this);
setContentView(mGLView);
// Get the size of the mGLView after the layout happens
mGLView.post(new Runnable() {
@Override
public void run() {
Cocos2dxActivity.screenHeight = mGLView.getHeight();
Cocos2dxActivity.screenWidth = mGLView.getWidth();
}
});
}
@Override

View File

@ -29,8 +29,6 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import android.view.WindowManager;
/**
*

View File

@ -38,8 +38,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
public class Cocos2dxActivity extends Activity{
public static int screenWidth;
public static int screenHeight;
private static Cocos2dxMusic backgroundMusicPlayer;
private static Cocos2dxSound soundPlayer;
private static Cocos2dxAccelerometer accelerometer;
@ -57,8 +55,6 @@ public class Cocos2dxActivity extends Activity{
// get frame size
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
screenWidth = dm.widthPixels;
screenHeight = dm.heightPixels;
accelerometer = new Cocos2dxAccelerometer(this);
// init media player and sound player
@ -224,7 +220,7 @@ public class Cocos2dxActivity extends Activity{
Dialog dialog = new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setPositiveButton("Ok",
.setPositiveButton("Ok",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton){

View File

@ -146,7 +146,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
protected void initView() {
mRenderer = new Cocos2dxRenderer();
mRenderer = new Cocos2dxRenderer();
setFocusableInTouchMode(true);
setRenderer(mRenderer);
@ -184,7 +184,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
mainView = this;
}
public void onPause(){
public void onPause(){
queueEvent(new Runnable() {
@Override
public void run() {
@ -297,8 +297,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_DOWN:
// there are only one finger on the screen
final int idDown = event.getPointerId(0);
final float xDown = event.getX(idDown);
final float yDown = event.getY(idDown);
final float xDown = xs[0];
final float yDown = ys[0];
queueEvent(new Runnable() {
@Override
@ -333,8 +333,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_UP:
// there are only one finger on the screen
final int idUp = event.getPointerId(0);
final float xUp = event.getX(idUp);
final float yUp = event.getY(idUp);
final float xUp = xs[0];
final float yUp = ys[0];
queueEvent(new Runnable() {
@Override
@ -360,6 +360,13 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
return true;
}
/*
* This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct.
*/
protected void onSizeChanged(int w, int h, int oldw, int oldh){
this.mRenderer.setScreenWidthAndHeight(w, h);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
final int kc = keyCode;
@ -374,6 +381,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
return super.onKeyDown(keyCode, event);
}
// Show an event in the LogCat view, for debugging
private void dumpEvent(MotionEvent event) {
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,

View File

@ -33,11 +33,18 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
private final static long NANOSECONDSPERMINISECOND = 1000000;
private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND);
private long last;
private int screenWidth;
private int screenHeight;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(Cocos2dxActivity.screenWidth, Cocos2dxActivity.screenHeight);
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(screenWidth, screenHeight);
last = System.nanoTime();
}
public void setScreenWidthAndHeight(int w, int h){
this.screenWidth = w;
this.screenHeight = h;
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
}

View File

@ -57,7 +57,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -1 +1 @@
0eeb5b0e70a2884281fd6d16e58654dd2012c7ce
8575c43b860eea3c0f02d9543e58b74073e40e6d

View File

@ -41,16 +41,6 @@ public class ApplicationDemo extends Cocos2dxActivity{
setContentView(R.layout.helloworld_demo);
mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.helloworld_gl_surfaceview);
mGLView.setTextField((EditText)findViewById(R.id.textField));
// Get the size of the mGLView after the layout happens
mGLView.post(new Runnable() {
@Override
public void run() {
Cocos2dxActivity.screenHeight = mGLView.getHeight();
Cocos2dxActivity.screenWidth = mGLView.getWidth();
}
});
}
@Override

View File

@ -29,8 +29,6 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import android.view.WindowManager;
/**
*

View File

@ -38,8 +38,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
public class Cocos2dxActivity extends Activity{
public static int screenWidth;
public static int screenHeight;
private static Cocos2dxMusic backgroundMusicPlayer;
private static Cocos2dxSound soundPlayer;
private static Cocos2dxAccelerometer accelerometer;
@ -57,8 +55,6 @@ public class Cocos2dxActivity extends Activity{
// get frame size
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
screenWidth = dm.widthPixels;
screenHeight = dm.heightPixels;
accelerometer = new Cocos2dxAccelerometer(this);
// init media player and sound player

View File

@ -146,7 +146,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
protected void initView() {
mRenderer = new Cocos2dxRenderer();
mRenderer = new Cocos2dxRenderer();
setFocusableInTouchMode(true);
setRenderer(mRenderer);
@ -297,8 +297,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_DOWN:
// there are only one finger on the screen
final int idDown = event.getPointerId(0);
final float xDown = event.getX(idDown);
final float yDown = event.getY(idDown);
final float xDown = xs[0];
final float yDown = ys[0];
queueEvent(new Runnable() {
@Override
@ -333,8 +333,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_UP:
// there are only one finger on the screen
final int idUp = event.getPointerId(0);
final float xUp = event.getX(idUp);
final float yUp = event.getY(idUp);
final float xUp = xs[0];
final float yUp = ys[0];
queueEvent(new Runnable() {
@Override
@ -360,6 +360,13 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
return true;
}
/*
* This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct.
*/
protected void onSizeChanged(int w, int h, int oldw, int oldh){
this.mRenderer.setScreenWidthAndHeight(w, h);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
final int kc = keyCode;
@ -374,6 +381,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
return super.onKeyDown(keyCode, event);
}
// Show an event in the LogCat view, for debugging
private void dumpEvent(MotionEvent event) {
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,

View File

@ -33,11 +33,18 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
private final static long NANOSECONDSPERMINISECOND = 1000000;
private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND);
private long last;
private int screenWidth;
private int screenHeight;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(Cocos2dxActivity.screenWidth, Cocos2dxActivity.screenHeight);
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(screenWidth, screenHeight);
last = System.nanoTime();
}
public void setScreenWidthAndHeight(int w, int h){
this.screenWidth = w;
this.screenHeight = h;
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
}

View File

@ -57,7 +57,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -1 +1 @@
98ff4ef0fe1ad1b9c73649d4a4e42796662e335a
c1cdd4b0d66de5127dc37f73eb9895737ca3e18d

View File

@ -338,7 +338,7 @@ static CGSize _caculateStringSizeWithFontOrZFont(NSString *str, id font, CGSize
CGSize tmp;
if (isZfont)
{
[FontLabelStringDrawingHelper sizeWithZFont:str zfont:font];
tmp = [FontLabelStringDrawingHelper sizeWithZFont:str zfont:font];
}
else
{

View File

@ -31,7 +31,7 @@ PROJECT_NAME = cocos2d-x
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.0.1-x-0.9.1
PROJECT_NUMBER = 1.0.1-x-0.9.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
@ -1456,7 +1456,8 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED =
PREDEFINED = "CC_PROPERTY_READONLY(varType, varName, funName)=protected: varType varName;\n/** get##funName*/\n public: virtual varType get##funName(void);" \
"CC_PROPERTY(varType, varName, funName)=protected: varType varName;\n/** get##funName*/\n public: virtual varType get##funName(void);\n/** set##funName*/\n public: virtual void set##funName(varType var);"
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.

View File

@ -101,13 +101,13 @@ copy_base_files(){
copy_cocos2d_files(){
echo ...copying cocos2d files
copy_files cocos2dx "$LIBS_DIR"
copy_files LICENSE.cocos2d-x "$LIBS_DIR"
copy_files licenses/LICENSE_cocos2d-x.txt "$LIBS_DIR"
}
copy_cocosdenshion_files(){
echo ...copying CocosDenshion files
copy_files CocosDenshion "$LIBS_DIR"
# copy_files LICENSE_CocosDenshion.txt "$LIBS_DIR"
# copy_files licenses/LICENSE_CocosDenshion.txt "$LIBS_DIR"
}
# copy_cocosdenshionextras_files(){
@ -118,7 +118,7 @@ copy_cocosdenshion_files(){
# copy_fontlabel_files(){
# echo ...copying FontLabel files
# copy_files external/FontLabel "$LIBS_DIR"
# copy_files LICENSE_FontLabel.txt "$LIBS_DIR"
# copy_files licenses/LICENSE_FontLabel.txt "$LIBS_DIR"
# }
# copy_cocoslive_files(){
@ -127,7 +127,7 @@ copy_cocosdenshion_files(){
# echo ...copying TouchJSON files
# copy_files external/TouchJSON "$LIBS_DIR"
# copy_files LICENSE_TouchJSON.txt "$LIBS_DIR"
# copy_files licenses/LICENSE_TouchJSON.txt "$LIBS_DIR"
# }
print_template_banner(){
@ -285,7 +285,7 @@ copy_xcode4_project_templates(){
echo ...copying Chipmunk files
copy_files chipmunk "$LIBS_DIR"
copy_files LICENSE.chipmunk "$LIBS_DIR"
copy_files licenses/LICENSE_chipmunk.txt "$LIBS_DIR"
echo done!
@ -297,7 +297,7 @@ copy_xcode4_project_templates(){
echo ...copying Box2D files
copy_files Box2D "$LIBS_DIR"
copy_files LICENSE.box2d "$LIBS_DIR"
copy_files licenses/LICENSE_box2d.txt "$LIBS_DIR"
echo done!
@ -310,8 +310,8 @@ copy_xcode4_project_templates(){
echo ...copying lua files
copy_files lua "$LIBS_DIR"
copy_files LICENSE.lua "$LIBS_DIR"
copy_files LICENSE.tolua++ "$LIBS_DIR"
copy_files licenses/LICENSE_lua.txt "$LIBS_DIR"
copy_files licenses/LICENSE_tolua++.txt "$LIBS_DIR"
echo done!

View File

@ -42,7 +42,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -42,7 +42,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -42,7 +42,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -42,7 +42,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -41,7 +41,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -41,7 +41,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview:__glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -41,7 +41,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview:__glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -1,8 +1,10 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;
using namespace CocosDenshion;
AppDelegate::AppDelegate()
:m_pLuaEngine(NULL)
@ -11,6 +13,8 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
// end simple audio engine here, or it may crashed on win32
SimpleAudioEngine::sharedEngine()->end();
CCScriptEngineManager::sharedScriptEngineManager()->removeScriptEngine();
CC_SAFE_DELETE(m_pLuaEngine);
}
@ -105,35 +109,9 @@ bool AppDelegate::applicationDidFinishLaunching()
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// CCLuaScriptModule::sharedLuaScriptModule()->executeScriptFile("./../../HelloLua/Resource/hello.lua");
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile("./../../HelloLua/Resource/hello.lua");
/*
* Another way to run lua script.
* Load the file into memory and run it.
*
unsigned long size;
char *pFileContent = (char*)CCFileUtils::getFileData("./../../HelloLua/Resource/hello.lua", "r", &size);
if (pFileContent)
{
// copy the file contents and add '\0' at the end, or the lua parser can not parse it
char *pTmp = new char[size + 1];
pTmp[size] = '\0';
memcpy(pTmp, pFileContent, size);
delete[] pFileContent;
string code(pTmp);
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->excuteScriptFile(code);
delete []pTmp;
}
*/
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
printf("%s", path.c_str());
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile(path.c_str());
#endif

View File

@ -1,3 +1,7 @@
require "hello2"
cocos2d.CCLuaLog("result is " .. myadd(3, 5))
-- create scene & layer
layerFarm = cocos2d.CCLayer:node()
layerFarm:setIsTouchEnabled(true)
@ -31,6 +35,7 @@ function btnTouchMove(e)
end
function btnTouchBegin(e)
cocos2d.CCScheduler:sharedScheduler():unscheduleScriptFunc("tick")
cocos2d.CCLuaLog("btnTouchBegin")
for k,v in ipairs(e) do
pointBegin = v:locationInView(v:view())
@ -132,7 +137,7 @@ layerMenu:addChild(menuTools)
function tick()
point = spriteDog:getPosition();
local point = spriteDog:getPosition();
if point.x > winSize.width then
point.x = 0
@ -144,10 +149,16 @@ function tick()
end
-- avoid memory leak
collectgarbage( "setpause", 100)
collectgarbage( "setstepmul", 5000)
cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc("tick", 0.01, false)
-- run
-- play background music
CocosDenshion.SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true);
-- preload effect
CocosDenshion.SimpleAudioEngine:sharedEngine():preloadEffect("effect1.wav");
-- run
cocos2d.CCDirector:sharedDirector():runWithScene(sceneGame)

View File

@ -0,0 +1,3 @@
function myadd(x, y)
return x + y
end

View File

@ -57,7 +57,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview:__glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];

View File

@ -29,8 +29,6 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import android.view.WindowManager;
/**
*

View File

@ -38,8 +38,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
public class Cocos2dxActivity extends Activity{
public static int screenWidth;
public static int screenHeight;
private static Cocos2dxMusic backgroundMusicPlayer;
private static Cocos2dxSound soundPlayer;
private static Cocos2dxAccelerometer accelerometer;
@ -57,8 +55,6 @@ public class Cocos2dxActivity extends Activity{
// get frame size
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
screenWidth = dm.widthPixels;
screenHeight = dm.heightPixels;
accelerometer = new Cocos2dxAccelerometer(this);
// init media player and sound player
@ -224,7 +220,7 @@ public class Cocos2dxActivity extends Activity{
Dialog dialog = new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setPositiveButton("Ok",
.setPositiveButton("Ok",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton){

View File

@ -146,7 +146,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
protected void initView() {
mRenderer = new Cocos2dxRenderer();
mRenderer = new Cocos2dxRenderer();
setFocusableInTouchMode(true);
setRenderer(mRenderer);
@ -184,7 +184,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
mainView = this;
}
public void onPause(){
public void onPause(){
queueEvent(new Runnable() {
@Override
public void run() {
@ -297,8 +297,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_DOWN:
// there are only one finger on the screen
final int idDown = event.getPointerId(0);
final float xDown = event.getX(idDown);
final float yDown = event.getY(idDown);
final float xDown = xs[0];
final float yDown = ys[0];
queueEvent(new Runnable() {
@Override
@ -333,8 +333,8 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
case MotionEvent.ACTION_UP:
// there are only one finger on the screen
final int idUp = event.getPointerId(0);
final float xUp = event.getX(idUp);
final float yUp = event.getY(idUp);
final float xUp = xs[0];
final float yUp = ys[0];
queueEvent(new Runnable() {
@Override
@ -360,6 +360,13 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
return true;
}
/*
* This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct.
*/
protected void onSizeChanged(int w, int h, int oldw, int oldh){
this.mRenderer.setScreenWidthAndHeight(w, h);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
final int kc = keyCode;
@ -374,6 +381,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
}
return super.onKeyDown(keyCode, event);
}
// Show an event in the LogCat view, for debugging
private void dumpEvent(MotionEvent event) {
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,

View File

@ -33,11 +33,18 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
private final static long NANOSECONDSPERMINISECOND = 1000000;
private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND);
private long last;
private int screenWidth;
private int screenHeight;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(Cocos2dxActivity.screenWidth, Cocos2dxActivity.screenHeight);
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(screenWidth, screenHeight);
last = System.nanoTime();
}
public void setScreenWidthAndHeight(int w, int h){
this.screenWidth = w;
this.screenHeight = h;
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
}

View File

@ -42,16 +42,6 @@ public class TestsDemo extends Cocos2dxActivity{
setContentView(R.layout.test_demo);
mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.test_demo_gl_surfaceview);
mGLView.setTextField((EditText)findViewById(R.id.textField));
// Get the size of the mGLView after the layout happens
mGLView.post(new Runnable() {
@Override
public void run() {
Cocos2dxActivity.screenHeight = mGLView.getHeight();
Cocos2dxActivity.screenWidth = mGLView.getWidth();
}
});
}
@Override

View File

@ -44,7 +44,7 @@ static AppDelegate s_sharedApplication;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:true];

View File

@ -1 +1 @@
7f6876c61c14e898650f3d05e393ca501a0f86f0
3df87510e48dfe7e5c768dcef3f4fd6eb99a129b

View File

@ -9,21 +9,13 @@ enum {
};
static int fontIdx = 0;
static std::string fontList[] =
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
static std::string fontList[] =
{
"American Typewriter",
"American Typewriter",
"Marker Felt",
"A Damn Mess",
"Abberancy",
"Abduction",
"Paint Boy",
"Schwarzwald Regular",
"Scissor Cuts",
};
#else
static std::string fontList[] =
{
#endif
"fonts/A Damn Mess.ttf",
"fonts/Abberancy.ttf",
"fonts/Abduction.ttf",
@ -31,7 +23,6 @@ static std::string fontList[] =
"fonts/Schwarzwald Regular.ttf",
"fonts/Scissor Cuts.ttf",
};
#endif
static const char* nextAction(void)
{

View File

@ -2,23 +2,23 @@ pushd ../../
echo "generating libcocos2dx"
mkdir -p template/xcode4/lib_cocos2dx.xctemplate
python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone third_party CCImage.cpp CCFileUtils.cpp Android.mk" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist
python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone third_party CCImage.cpp CCFileUtils.cpp Android.mk Linux linux" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist
echo "generating libcocosdenshion"
mkdir -p template/xcode4/lib_cocosdenshion.xctemplate
python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist
python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 airplay wophone third_party Android.mk Linux linux" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist
echo "generating libbox2d"
mkdir -p template/xcode4/lib_box2d.xctemplate
python ./tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist
python ./tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "android win32 airplay wophone Android.mk Linux linux" > ./template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist
echo "generating libchipmunk"
mkdir -p template/xcode4/lib_chipmunk.xctemplate
python ./tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist
python ./tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "android win32 airplay wophone Android.mk Linux linux CMakeFiles Makefile" > ./template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist
echo "generating liblua"
mkdir -p template/xcode4/lib_lua.xctemplate
python ./tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --exclude "android win32 airplay wophone Makefile" > ./template/xcode4/lib_lua.xctemplate/TemplateInfo.plist
python ./tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --exclude "android win32 airplay wophone Makefile Linux linux CMakeFiles" > ./template/xcode4/lib_lua.xctemplate/TemplateInfo.plist
echo "done"