mirror of https://github.com/axmolengine/axmol.git
Merge remote-tracking branch 'origin/gles20' into gles20
This commit is contained in:
commit
3befb0ffdc
|
@ -36,13 +36,13 @@ CCApplication* CCApplication::sm_pSharedApplication = 0;
|
|||
|
||||
CCApplication::CCApplication()
|
||||
{
|
||||
CC_ASSERT(! sm_pSharedApplication);
|
||||
CCAssert(! sm_pSharedApplication, "sm_pSharedApplication already exist");
|
||||
sm_pSharedApplication = this;
|
||||
}
|
||||
|
||||
CCApplication::~CCApplication()
|
||||
{
|
||||
CC_ASSERT(this == sm_pSharedApplication);
|
||||
CCAssert(this == sm_pSharedApplication, "sm_pSharedApplication != this");
|
||||
sm_pSharedApplication = 0;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ TargetPlatform CCApplication::getTargetPlatform()
|
|||
|
||||
CCApplication* CCApplication::sharedApplication()
|
||||
{
|
||||
CC_ASSERT(sm_pSharedApplication);
|
||||
CCAssert(sm_pSharedApplication, "sm_pSharedApplication not set");
|
||||
return sm_pSharedApplication;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.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:
|
||||
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 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.
|
||||
****************************************************************************/
|
||||
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.
|
||||
****************************************************************************/
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -323,44 +323,44 @@ std::string CCFileUtils::getWriteablePath()
|
|||
|
||||
unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize)
|
||||
{
|
||||
unsigned char * pBuffer = NULL;
|
||||
unzFile pFile = NULL;
|
||||
*pSize = 0;
|
||||
unsigned char * pBuffer = NULL;
|
||||
unzFile pFile = NULL;
|
||||
*pSize = 0;
|
||||
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!pszZipFilePath || !pszFileName);
|
||||
CC_BREAK_IF(strlen(pszZipFilePath) == 0);
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!pszZipFilePath || !pszFileName);
|
||||
CC_BREAK_IF(strlen(pszZipFilePath) == 0);
|
||||
|
||||
pFile = unzOpen(pszZipFilePath);
|
||||
CC_BREAK_IF(!pFile);
|
||||
pFile = unzOpen(pszZipFilePath);
|
||||
CC_BREAK_IF(!pFile);
|
||||
|
||||
int nRet = unzLocateFile(pFile, pszFileName, 1);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
int nRet = unzLocateFile(pFile, pszFileName, 1);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
|
||||
char szFilePathA[260];
|
||||
unz_file_info FileInfo;
|
||||
nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
char szFilePathA[260];
|
||||
unz_file_info FileInfo;
|
||||
nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
|
||||
nRet = unzOpenCurrentFile(pFile);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
nRet = unzOpenCurrentFile(pFile);
|
||||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
|
||||
pBuffer = new unsigned char[FileInfo.uncompressed_size];
|
||||
int nSize = 0;
|
||||
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
|
||||
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
|
||||
pBuffer = new unsigned char[FileInfo.uncompressed_size];
|
||||
int nSize = 0;
|
||||
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
|
||||
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
|
||||
|
||||
*pSize = FileInfo.uncompressed_size;
|
||||
unzCloseCurrentFile(pFile);
|
||||
} while (0);
|
||||
*pSize = FileInfo.uncompressed_size;
|
||||
unzCloseCurrentFile(pFile);
|
||||
} while (0);
|
||||
|
||||
if (pFile)
|
||||
{
|
||||
unzClose(pFile);
|
||||
}
|
||||
if (pFile)
|
||||
{
|
||||
unzClose(pFile);
|
||||
}
|
||||
|
||||
return pBuffer;
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -340,8 +340,8 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
|
|||
{
|
||||
bool bRet = false;
|
||||
|
||||
CCAssert( pText, @"Invalid pText");
|
||||
CCAssert( pInfo, @"Invalid pInfo");
|
||||
CCAssert(pText, "Invalid pText");
|
||||
CCAssert(pInfo, "Invalid pInfo");
|
||||
|
||||
do {
|
||||
NSString * string = [NSString stringWithUTF8String:pText];
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
|
||||
#define CC_DLL
|
||||
|
||||
#if CC_DISABLE_ASSERT > 0
|
||||
#define CC_ASSERT(cond)
|
||||
#else
|
||||
#define CC_ASSERT(cond) assert(cond)
|
||||
|
||||
#endif
|
||||
|
||||
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
|||
CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
||||
{
|
||||
CCSprite *pobSprite = new CCSprite();
|
||||
if (pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
|
||||
if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
|
||||
{
|
||||
pobSprite->autorelease();
|
||||
return pobSprite;
|
||||
|
@ -153,9 +153,12 @@ CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
{
|
||||
CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);
|
||||
|
||||
#if COCOS2D_DEBUG > 0
|
||||
char msg[256] = {0};
|
||||
sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName);
|
||||
CCAssert(pFrame != NULL, msg);
|
||||
#endif
|
||||
|
||||
return createWithSpriteFrame(pFrame);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
//
|
||||
// http://www.cocos2d-iphone.org
|
||||
// http://www.cocos2d-html5.org
|
||||
// http://www.cocos2d-x.org
|
||||
//
|
||||
// Javascript + cocos2d actions tests
|
||||
//
|
||||
|
||||
require("js/helper.js");
|
||||
|
||||
director = cc.Director.getInstance();
|
||||
winSize = director.getWinSize();
|
||||
centerPos = cc.p( winSize.width/2, winSize.height/2 );
|
||||
|
||||
scenes = []
|
||||
currentScene = 0;
|
||||
|
||||
nextScene = function () {
|
||||
currentScene = currentScene + 1;
|
||||
if( currentScene >= scenes.length )
|
||||
currentScene = 0;
|
||||
|
||||
withTransition = true;
|
||||
loadScene(currentScene);
|
||||
};
|
||||
|
||||
previousScene = function () {
|
||||
currentScene = currentScene -1;
|
||||
if( currentScene < 0 )
|
||||
currentScene = scenes.length -1;
|
||||
|
||||
withTransition = true;
|
||||
loadScene(currentScene);
|
||||
};
|
||||
|
||||
restartScene = function () {
|
||||
loadScene( currentScene );
|
||||
};
|
||||
|
||||
loadScene = function (sceneIdx)
|
||||
{
|
||||
winSize = director.getWinSize();
|
||||
centerPos = cc.p( winSize.width/2, winSize.height/2 );
|
||||
|
||||
var scene = new cc.Scene();
|
||||
scene.init();
|
||||
var layer = new scenes[ sceneIdx ]();
|
||||
|
||||
scene.addChild( layer );
|
||||
|
||||
// scene.walkSceneGraph(0);
|
||||
|
||||
director.replaceScene( scene );
|
||||
// __jsc__.garbageCollect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Base Layer
|
||||
//
|
||||
|
||||
BaseLayer = cc.LayerGradient.extend({
|
||||
|
||||
ctor:function () {
|
||||
|
||||
var parent = new cc.LayerGradient();
|
||||
__associateObjWithNative(this, parent);
|
||||
this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255));
|
||||
},
|
||||
|
||||
title:function () {
|
||||
return "No Title";
|
||||
},
|
||||
|
||||
subtitle:function () {
|
||||
return "";
|
||||
},
|
||||
|
||||
code:function () {
|
||||
return "";
|
||||
},
|
||||
|
||||
restartCallback:function (sender) {
|
||||
restartScene();
|
||||
},
|
||||
|
||||
nextCallback:function (sender) {
|
||||
nextScene();
|
||||
},
|
||||
|
||||
backCallback:function (sender) {
|
||||
previousScene();
|
||||
},
|
||||
|
||||
onEnter:function () {
|
||||
// DO NOT CALL this._super()
|
||||
// this._super();
|
||||
|
||||
// add title and subtitle
|
||||
var label = cc.LabelTTF.create(this.title(), "Arial", 28);
|
||||
this.addChild(label, 1);
|
||||
label.setPosition( cc.p(winSize.width / 2, winSize.height - 40));
|
||||
|
||||
var strSubtitle = this.subtitle();
|
||||
if (strSubtitle != "") {
|
||||
var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16);
|
||||
this.addChild(l, 1);
|
||||
l.setPosition( cc.p(winSize.width / 2, winSize.height - 70));
|
||||
}
|
||||
|
||||
var strCode = this.code();
|
||||
if( strCode !="" ) {
|
||||
var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16);
|
||||
label.setPosition( cc.p( winSize.width/2, winSize.height-120) );
|
||||
this.addChild( label,10 );
|
||||
|
||||
var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16);
|
||||
labelbg.setColor( cc.c3b(10,10,255) );
|
||||
labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) );
|
||||
this.addChild( labelbg,9);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// MainTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
MainTest = BaseLayer.extend({
|
||||
|
||||
_menu : null,
|
||||
|
||||
onEnter:function () {
|
||||
this._super();
|
||||
|
||||
cc.MenuItemFont.setFontSize(24);
|
||||
var item1 = cc.MenuItemFont.create("Actions: Basic Tests", this, function() { require("js/test-actions.js"); } );
|
||||
var item2 = cc.MenuItemFont.create("Actions: Ease Tests", this, function() { require("js/test-easeactions.js"); } );
|
||||
var item3 = cc.MenuItemFont.create("Actions: Progress Tests", this, function() { require("js/test-actionsprogress.js"); } );
|
||||
var item4 = cc.MenuItemFont.create("Chipmunk Tests", this, function() { require("js/test-chipmunk.js"); } );
|
||||
var item5 = cc.MenuItemFont.create("Effects Tests", this, function() { require("js/test-effects.js"); } );
|
||||
var item6 = cc.MenuItemFont.create("Label Tests", this, function() { require("js/test-label.js"); } );
|
||||
var item7 = cc.MenuItemFont.create("Menu Tests", this, function() { require("js/test-menu.js"); } );
|
||||
var item8 = cc.MenuItemFont.create("Parallax Tests", this, function() { require("js/test-parallax.js"); } );
|
||||
var item9 = cc.MenuItemFont.create("Particle Tests", this, function() { require("js/test-particles.js"); } );
|
||||
var item10 = cc.MenuItemFont.create("RenderTexture Tests", this, function() { require("js/test-rendertexture.js"); } );
|
||||
var item11 = cc.MenuItemFont.create("Sprite Tests", this, function() { require("js/test-sprite.js"); } );
|
||||
var item12 = cc.MenuItemFont.create("Tilemap Tests", this, function() { require("js/test-tilemap.js"); } );
|
||||
var item13 = cc.MenuItemFont.create("CocosDenshion Tests", this, function() { require("js/test-cocosdenshion.js"); } );
|
||||
var item14 = cc.MenuItemFont.create("cocos2d presentation", this, function() { require("js/test-cocos2djs.js"); } );
|
||||
var item14 = cc.MenuItemFont.create("Performance test", this, function() { require("js/PerformanceTest/PerformanceTest.js"); } );
|
||||
|
||||
|
||||
this._menu = cc.Menu.create( item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14 );
|
||||
this._menu.alignItemsVertically();
|
||||
|
||||
this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) );
|
||||
|
||||
this.addChild( this._menu );
|
||||
|
||||
var platform = __getPlatform();
|
||||
if( platform.substring(0,7) == 'desktop' )
|
||||
this.setMouseEnabled( true );
|
||||
else if( platform.substring(0,6) == 'mobile' )
|
||||
this.setTouchEnabled( true );
|
||||
},
|
||||
|
||||
onTouchesMoved:function (touches, event) {
|
||||
var delta = touches[0].getDelta();
|
||||
var current = this._menu.getPosition();
|
||||
this._menu.setPosition( cc.p( current.x, current.y + delta.y ) );
|
||||
return true;
|
||||
},
|
||||
|
||||
onMouseDragged : function( event ) {
|
||||
var delta = event.getDelta();
|
||||
var current = this._menu.getPosition();
|
||||
this._menu.setPosition( cc.p( current.x, current.y + delta.y ) );
|
||||
return true;
|
||||
},
|
||||
|
||||
title:function () {
|
||||
return "Javascript tests";
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// Order of tests
|
||||
//
|
||||
|
||||
scenes.push( MainTest);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Main entry point
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
function run()
|
||||
{
|
||||
var scene = cc.Scene.create();
|
||||
var layer = new scenes[currentScene]();
|
||||
scene.addChild( layer );
|
||||
|
||||
var runningScene = director.getRunningScene();
|
||||
if( runningScene == null )
|
||||
director.runWithScene( scene );
|
||||
else
|
||||
director.replaceScene( cc.TransitionSplitCols.create(1, scene ) );
|
||||
|
||||
director.setDisplayStats(true);
|
||||
}
|
||||
|
||||
run();
|
||||
|
|
@ -104,7 +104,7 @@ int CCLuaEngine::executeString(const char *codes)
|
|||
int CCLuaEngine::executeScriptFile(const char* filename)
|
||||
{
|
||||
int nRet = luaL_dofile(m_state, filename);
|
||||
// lua_gc(m_state, LUA_GCCOLLECT, 0);
|
||||
// lua_gc(m_state, LUA_GCCOLLECT, 0);
|
||||
|
||||
if (nRet != 0)
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ int CCLuaEngine::executeScriptFile(const char* filename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CCLuaEngine::executeGlobalFunction(const char* functionName)
|
||||
int CCLuaEngine::executeGlobalFunction(const char* functionName)
|
||||
{
|
||||
lua_getglobal(m_state, functionName); /* query function by name, stack: function */
|
||||
if (!lua_isfunction(m_state, -1))
|
||||
|
@ -126,7 +126,7 @@ int CCLuaEngine::executeGlobalFunction(const char* functionName)
|
|||
}
|
||||
|
||||
int error = lua_pcall(m_state, 0, 1, 0); /* call function, stack: ret */
|
||||
// lua_gc(m_state, LUA_GCCOLLECT, 0);
|
||||
// lua_gc(m_state, LUA_GCCOLLECT, 0);
|
||||
|
||||
if (error)
|
||||
{
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
12a58290deb3c79169fcb192e45b92d7229da0b3
|
Loading…
Reference in New Issue