Skip to content

Commit

Permalink
Merge branch 'master' of github.com:chukong/quick-cocos2d-x
Browse files Browse the repository at this point in the history
  • Loading branch information
hugohuang1111 committed Dec 15, 2014
2 parents 020094e + b5c6cc7 commit 7647e93
Show file tree
Hide file tree
Showing 378 changed files with 30,093 additions and 114,544 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.5plus
2.2.6
1 change: 1 addition & 0 deletions bin/lib/compile_scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
array('ex', 'extname', 1, 'lua', 'encrypted file extension name (default is "lua"), only valid for xxtea_chunk'),
array('c', 'config', 1, null, 'load options from config file'),
array('q', 'quiet', 0, false, 'quiet'),
array('luac', 'luac', 0, false, 'using luac compile framework'),
);

function errorhelp()
Expand Down
2 changes: 1 addition & 1 deletion bin/lib/quick/ScriptsCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected function compileModules(array $modules, $key = null, $sign = null)
$modulesBytes = array();
foreach ($modules as $path => $module)
{
$bytes = getScriptFileBytecodes($path, $module['tempFilePath']);
$bytes = getScriptFileBytecodes($path, $module['tempFilePath'], $this->config['luac']);
if ($xxtea)
{
$bytes = $sign . $xxtea->encrypt($bytes);
Expand Down
16 changes: 13 additions & 3 deletions bin/lib/quick/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
if (DS == '/')
{
define('LUAJIT_BIN', 'luajit');
define('LUA_BIN', BIN_DIR . '/mac/luac');
}
else
{
define('LUAJIT_BIN', BIN_DIR . '\\win32\\luajit.exe');
define('LUA_BIN', BIN_DIR . '\\win32\\luac.exe');
}

// helper functions
Expand Down Expand Up @@ -126,7 +128,7 @@ function findFiles($dir, array & $files)

while (($file = readdir($dh)) !== false)
{
if ($file{0} == '.') { continue; }
if ($file == '.' || $file == '..' || $file == ".DS_Store") { continue; }

$path = $dir . $file;
if (is_dir($path))
Expand All @@ -141,7 +143,7 @@ function findFiles($dir, array & $files)
closedir($dh);
}

function getScriptFileBytecodes($path, $tmpfile)
function getScriptFileBytecodes($path, $tmpfile, $usingluac = 0)
{
if (!file_exists($path))
{
Expand All @@ -159,7 +161,15 @@ function getScriptFileBytecodes($path, $tmpfile)
}

@mkdir(pathinfo($tmpfile, PATHINFO_DIRNAME), 0777, true);
$command = sprintf('%s -b -s "%s" "%s"', LUAJIT_BIN, $path, $tmpfile);

if ($usingluac == 0)
{
$command = sprintf('%s -b -s "%s" "%s"', LUAJIT_BIN, $path, $tmpfile);
}
else
{
$command = sprintf('%s -o "%s" "%s"', LUA_BIN, $tmpfile, $path);
}
passthru($command);

if (!file_exists($tmpfile))
Expand Down
Binary file added bin/mac/luac
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/make_framework_package.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR/../"
"$DIR/compile_scripts.sh" -i framework -o lib/framework_precompiled/framework_precompiled.zip -p framework -m zip
"$DIR/compile_scripts.sh" -i framework -o lib/framework_precompiled/framework_precompiled.zip -p framework -m zip -luac

echo ""
echo "### UPDATING ###"
Expand Down
2 changes: 1 addition & 1 deletion lib/cocos2d-x/cocos2dx/cocos2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NS_CC_BEGIN

const char* cocos2dVersion()
{
return "quick-cocos2d-x 2.2.5plus";
return "quick-cocos2d-x 2.2.6";
}

NS_CC_END
Expand Down
4 changes: 2 additions & 2 deletions lib/cocos2d-x/cocos2dx/include/cocos2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ THE SOFTWARE.
#define __COCOS2D_H__

// 0x00 HI ME LO
// 00 02 01 00
#define COCOS2D_VERSION 0x00020100
// 00 02 02 05
#define COCOS2D_VERSION 0x00020206

//
// all cocos2d include files
Expand Down
2 changes: 1 addition & 1 deletion lib/cocos2d-x/cocos2dx/kazmath/src/mat4.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ kmMat4* const kmMat4Transpose(kmMat4* pOut, const kmMat4* pIn)
*/
kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2)
{
#if defined(__ARM_NEON__)
#if defined(__ARM_ARCH_7)

float mat[16];

Expand Down
2 changes: 1 addition & 1 deletion lib/cocos2d-x/cocos2dx/kazmath/src/neon_matrix_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "kazmath/neon_matrix_impl.h"

#if defined(__ARM_NEON__)
#if defined(__ARM_ARCH_7)

void NEON_Matrix4Mul(const float* a, const float* b, float* output )
{
Expand Down
2 changes: 1 addition & 1 deletion lib/cocos2d-x/cocos2dx/misc_nodes/CCClippingNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void CCClippingNode::visit()
// this means that operation like glClear or glStencilOp will be masked with this value
glStencilMask(mask_layer);

glClear(GL_STENCIL_BUFFER_BIT);
//glClear(GL_STENCIL_BUFFER_BIT);
// manually save the depth test state
//GLboolean currentDepthTestEnabled = GL_TRUE;
GLboolean currentDepthWriteMask = GL_TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void showEditTextDialog(final String pTitle, final String pContent, final
public void runOnGLThread(final Runnable pRunnable) {
this.mGLSurfaceView.queueEvent(pRunnable);
}

protected static FrameLayout mFrameLayout;
// ===========================================================
// Methods
// ===========================================================
Expand All @@ -123,8 +123,8 @@ public void init() {
ViewGroup.LayoutParams framelayout_params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
FrameLayout framelayout = new FrameLayout(this);
framelayout.setLayoutParams(framelayout_params);
mFrameLayout = new FrameLayout(this);
mFrameLayout.setLayoutParams(framelayout_params);

// Cocos2dxEditText layout
ViewGroup.LayoutParams edittext_layout_params =
Expand All @@ -134,15 +134,15 @@ public void init() {
edittext.setLayoutParams(edittext_layout_params);

// ...add to FrameLayout
framelayout.addView(edittext);
mFrameLayout.addView(edittext);

// Cocos2dxGLSurfaceView
this.mGLSurfaceView = this.onCreateView();
//set id for GlSurfaceView, so can find by id and set focus on
this.mGLSurfaceView.setId(GLVIEW_ID);

// ...add to FrameLayout
framelayout.addView(this.mGLSurfaceView);
mFrameLayout.addView(this.mGLSurfaceView);

// Switch to supported OpenGL (ARGB888) mode on emulator
if (isAndroidEmulator())
Expand All @@ -152,7 +152,7 @@ public void init() {
this.mGLSurfaceView.setCocos2dxEditText(edittext);

// Set framelayout as the content view
setContentView(framelayout);
setContentView(mFrameLayout);
}

public Cocos2dxGLSurfaceView onCreateView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class Cocos2dxMusic {
private MediaPlayer mBackgroundMediaPlayer;
private float mLeftVolume;
private float mRightVolume;
private boolean mPaused;
private boolean mPaused;
private boolean mIsLoop = false;
private String mCurrentPath;

// ===========================================================
Expand Down Expand Up @@ -86,40 +87,42 @@ public void preloadBackgroundMusic(final String pPath) {
}
}

public void playBackgroundMusic(final String pPath, final boolean isLoop) {
if (this.mCurrentPath == null) {
public void playBackgroundMusic(final String path, final boolean isLoop) {
if (mCurrentPath == null) {
// it is the first time to play background music or end() was called
this.mBackgroundMediaPlayer = this.createMediaplayer(pPath);
this.mCurrentPath = pPath;
mBackgroundMediaPlayer = createMediaplayer(path);
mCurrentPath = path;
} else {
if (!this.mCurrentPath.equals(pPath)) {
if (!mCurrentPath.equals(path)) {
// play new background music

// release old resource and create a new one
if (this.mBackgroundMediaPlayer != null) {
this.mBackgroundMediaPlayer.release();
if (mBackgroundMediaPlayer != null) {
mBackgroundMediaPlayer.release();
}
this.mBackgroundMediaPlayer = this.createMediaplayer(pPath);
mBackgroundMediaPlayer = createMediaplayer(path);

// record the path
this.mCurrentPath = pPath;
mCurrentPath = path;
}
}

if (this.mBackgroundMediaPlayer == null) {
if (mBackgroundMediaPlayer == null) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null");
} else {
// if the music is playing or paused, stop it
this.mBackgroundMediaPlayer.stop();

this.mBackgroundMediaPlayer.setLooping(isLoop);

try {
this.mBackgroundMediaPlayer.prepare();
this.mBackgroundMediaPlayer.seekTo(0);
this.mBackgroundMediaPlayer.start();

this.mPaused = false;
// if the music is playing or paused, stop it
if (mPaused) {
mBackgroundMediaPlayer.seekTo(0);
mBackgroundMediaPlayer.start();
} else if (mBackgroundMediaPlayer.isPlaying()) {
mBackgroundMediaPlayer.seekTo(0);
} else {
mBackgroundMediaPlayer.start();
}
mBackgroundMediaPlayer.setLooping(isLoop);
mPaused = false;
mIsLoop = isLoop;
} catch (final Exception e) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state");
}
Expand All @@ -128,7 +131,8 @@ public void playBackgroundMusic(final String pPath, final boolean isLoop) {

public void stopBackgroundMusic() {
if (this.mBackgroundMediaPlayer != null) {
this.mBackgroundMediaPlayer.stop();
mBackgroundMediaPlayer.release();
mBackgroundMediaPlayer = createMediaplayer(mCurrentPath);

// should set the state, if not, the following sequence will be error
// play -> pause -> stop -> resume
Expand All @@ -152,17 +156,7 @@ public void resumeBackgroundMusic() {

public void rewindBackgroundMusic() {
if (this.mBackgroundMediaPlayer != null) {
this.mBackgroundMediaPlayer.stop();

try {
this.mBackgroundMediaPlayer.prepare();
this.mBackgroundMediaPlayer.seekTo(0);
this.mBackgroundMediaPlayer.start();

this.mPaused = false;
} catch (final Exception e) {
Log.e(Cocos2dxMusic.TAG, "rewindBackgroundMusic: error state");
}
playBackgroundMusic(mCurrentPath, mIsLoop);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,26 @@ public void onSurfaceChanged(final GL10 pGL10, final int pWidth, final int pHeig
@Override
public void onDrawFrame(final GL10 gl) {
/*
* FPS controlling algorithm is not accurate, and it will slow down FPS
* on some devices. So comment FPS controlling code.
* No need to use algorithm in default(60 FPS) situation,
* since onDrawFrame() was called by system 60 times per second by default.
*/

/*
final long nowInNanoSeconds = System.nanoTime();
final long interval = nowInNanoSeconds - this.mLastTickInNanoSeconds;
*/

// should render a frame when onDrawFrame() is called or there is a
// "ghost"
Cocos2dxRenderer.nativeRender();

/*
// fps controlling
if (interval < Cocos2dxRenderer.sAnimationInterval) {
try {
// because we render it before, so we should sleep twice time interval
Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
} catch (final Exception e) {
if (sAnimationInterval <= 1.0 / 60 * Cocos2dxRenderer.NANOSECONDSPERSECOND) {
Cocos2dxRenderer.nativeRender();
} else {
final long now = System.nanoTime();
final long remain = mLastTickInNanoSeconds + Cocos2dxRenderer.sAnimationInterval - now;
if (remain > 0) {
try {
Thread.sleep(remain / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
} catch (final Exception e) {
}
}
/*
* Render time MUST be counted in, or the FPS will slower than appointed.
*/
mLastTickInNanoSeconds = System.nanoTime();
Cocos2dxRenderer.nativeRender();
}
this.mLastTickInNanoSeconds = nowInNanoSeconds;
*/
}

// ===========================================================
Expand Down
Loading

0 comments on commit 7647e93

Please sign in to comment.