Giter Club home page Giter Club logo

cocos2d / cocos2d-x Goto Github PK

View Code? Open in Web Editor NEW
17.9K 17.9K 7.0K 965.55 MB

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.

Home Page: https://www.cocos.com/en/cocos2d-x

Python 0.71% Shell 0.09% CMake 0.64% C++ 85.69% Objective-C 0.64% C 2.64% Makefile 0.03% Objective-C++ 2.08% Java 1.31% GLSL 0.51% Lua 5.51% HTML 0.01% Csound Document 0.03% PLSQL 0.10% PowerShell 0.02% Batchfile 0.01% AIDL 0.01%
android c-plus-plus cocos2d cocos2d-x game-development game-engine gamedev ios linx lua metal windows

cocos2d-x's People

Contributors

2youyou2 avatar angeltown avatar boyu0 avatar carlomorgantinizynga avatar chengstory avatar chuanweizhang2013 avatar cocosrobot avatar dabingnn avatar darkdukey avatar dualface avatar folecr avatar geron-cn avatar j4m3z0r avatar jiusheng avatar minggo avatar mogemimi avatar nutty898 avatar pandamicro avatar patricejiang avatar pipu avatar ricardoquesada avatar rolandoam avatar samuele3hu avatar stammen avatar super626 avatar tangziwen avatar wenhailin avatar xiaofeng11 avatar yangws avatar zilongshanren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cocos2d-x's Issues

New iOs project won't build

cloned gles20 branch on 21-June-2012, reinstalled templates using install-templates-xcode.sh and the -f option. Created a new Xcode project using cocos2dx_box2d template. When building, I get 2 compile errors:

CCDrawingPrimitives.cpp: 'actions/CCActionCatmullRom.h' file not found
CCDirector.cpp: 'extensions/CCBReader/CCNodeLoaderLibrary.h' file not found

Explicit namespace qualifier is missing in macro definitions in CCObject.h

Macro definitions should involve full namespace qualification (to be independent from usage context).

Expected:
#define schedule_selector(_SELECTOR) (::cocos2d::SEL_SCHEDULE)(&_SELECTOR)
or even preferable
#define schedule_selector(_SELECTOR) static_cast<::cocos2d::SEL_SCHEDULE>(&_SELECTOR)

Actual:
#define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(&_SELECTOR)

The latter causes a compilation error if namespace cocos2d is not imported in user's code (to prevent namespace pollution for example):

// No using's.
auto const f = schedule_selector(DemoScene::Update); // error C2065: 'SEL_SCHEDULE' : undeclared identifier

Compiling with ndk-r7 still not working

Under windows, i can finally compile using ndk-r7 withouth problems (just some warnings) but the APK generated is not OK... at least i always get black screens with android 2.1 and 2.2 emulators (works with android 4 emulators).

This doens't happens with ndk-r6b.
I dont know about mac or unix, i just use cygwing, last cocos2dx stable and latest ndk r7.

CCBReader null pointer crash

CCBReader::readNodeGraphFromFile allows the pOwner parameter to be null (the default value is null, so this implies that null is a legal value for pOwner). However, CCBReader::readNodeGraphFromFile will crash when attempting to call pOwner->retain. If null is not a legal value, the default param value should be removed.

CCParticleSystemQuad crash when cleanup on win32

CCParticleSystemQuad cleanup crash on win32,, include removeFromParentAndCleanup(true) and setAutoRemoveOnFinish(true), tested cocos2d-2.0-rc2-x-2.0.1 and cocos2d-2.0-rc0a-x-2.0 have same issue

I tested my project and cocos2d-x->tests->AddAndDeleteParticleSystems example.

i tested IOS platform, it's fine.

addImageAsync() Does Not Cache Texture Data for Reloading on Resume

This is relevant to only Android as far as I'm aware (only tested Windows and Android).

While testing the app's behavior when it is paused and resumed, I noticed that when you call
void CCTextureCache::sharedTextureCache()->addImageAsync() The following series of steps does not call


So when the app resumes and you attempt to

```Only images added by calling addImage() get reloaded.

VolatileTexture::addImageTexture also does not get called when you call addPVRImage or addUIImage but i'm not sure how important addUIImage is for Android.

Also, i'm not sure if this is a problem but when you call 
```CCTextureCache::sharedTextureCache()->removeUnusedTextures()
```Any removed textures also do not get removed from the container
```std::list<VolatileTexture*> VolatileTexture::textures
```and therefore, get reloaded when the app returns to the foreground.

Linux 64-bit needs correct lib and header files

build-linux.sh doesn't copy the correct CocosDenshion fmod library for 64-bit. It should detect 64-bit and copy CocosDenshion/third_party/linux/fmod/lib64/api/lib/-.so files. It also needs to create a symlink for each of them on the fly, since the zip archive doesn't save proper symlink files (they extract to regular files libfmodex64.so and libfmodexL64.so).

The header files for 3rd party are still in 32-bit mode. For example, cocos2dx/platform/third_party/linux/curl/curbuild.h has wrong SIZEOF values.

Errors when running Build-win32.bat

I just downloaded cocos2d-x-cocos2d-0.99.5-x-0.8.2-124 and ran the Build-win32.bat script according to this tutorial

http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide

and I received the following errors:

"C:\gameDev\cocos2d-cocos2d-x-9613dce\cocos2d-win32.vc2010.sln" (default target
) (1) ->
"C:\gameDev\cocos2d-cocos2d-x-9613dce\cocos2dx\proj.win32\cocos2d-win32.vcxproj
" (default target) (5) ->
(Link target) ->
CCDirector.obj : error LNK2019: unresolved external symbol "public: static vo
id __cdecl cocos2d::CCUserDefault::purgeSharedUserDefault(void)" (?purgeSharedU
serDefault@CCUserDefault@cocos2d@@SAXXZ) referenced in function "protected: voi
d __thiscall cocos2d::CCDirector::purgeDirector(void)" (?purgeDirector@CCDirect
or@cocos2d@@IAEXXZ) [C:\gameDev\cocos2d-cocos2d-x-9613dce\cocos2dx\proj.win32\c
ocos2d-win32.vcxproj]
C:\gameDev\cocos2d-cocos2d-x-9613dce\Release.win32\libcocos2d.dll : fatal err
or LNK1120: 1 unresolved externals [C:\gameDev\cocos2d-cocos2d-x-9613dce\cocos2
dx\proj.win32\cocos2d-win32.vcxproj]

TargetConditionals.h could be included somewhere for iOS ?

Hi,

I just came across an issue where TARGET_IPHONE_SIMULATOR wasn't defined when I compiling for the iOS simulator.

I found out after some investigations that I needed to include the "TargetConditionals.h" file to get that macro defined.

Maybe that file could be added somewhere in iOS classes ? Not sure where though :/

thanks!

iOS5 and scale factor ?

Hi, I just upgraded my iphone 4 to iOS5 and the graphics are now all messed up in my cocos2d-x 1.0.1 game.
It does use the retina graphics but the positions are all messed up.

Everything runs fine on the 4.3 simulator, but I have same problem in the 5.0 simulator.

I tried to google and look in the CCDirector a hint on that bug but I couldn't find anything..

Is that a known issue ?

XCode templates dont work anymore: CCTouch::view() is missing

I tried using the current master branch (0ab4ead) to generate a new cocos2d-x project.
Compilation fails because CCTouch don't have the member function view() that is called somewhere in the tutorial (I dont have the test case anymore at hand but I guess it s easy to reproduce).

Crash when application closed and currently transition scene active

Application crashed when trying to exit, while changing scene (Transition active).
The debuger shows that it crashed on: CCTexture2d.cpp:81 ( In destructor: glDeleteTextures(1, &m_uName);)
This http://www.cocos2d-x.org/boards/12/topics/4738?r=4747 suggests that InScene doesn't receive onExit calls.
And it doesn't. There is a comment in CCTransition.cpp:onExit call:
"// inScene should not receive the onExit callback
// only the onEnterTransitionDidFinish"

But actually adding the onExit call does solves the crash.

Issue when loading CCControlButton from ccbi

I think there's a bug in cocos-2dx. If you look at CCControl.h (from CocosBuilder), you have the following block inside:

/** The possible state for a control.  */
enum 
{
    CCControlStateNormal       = 1 << 0, // The normal, or default state of a controlโ€”that is, enabled but neither selected nor highlighted.
    CCControlStateHighlighted  = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
    CCControlStateDisabled     = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
    CCControlStateSelected     = 1 << 3  // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
};

And when you have a look at CCControlButtonLoader.cpp in cocos2d-x, you have this:

...
#define PROPERTY_TITLE_DISABLED "title|3" 
...
#define PROPERTY_TITLECOLOR_DISABLED "titleColor|3" 
...
#define PROPERTY_TITLETTF_DISABLED "titleTTF|3" 
...
#define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|3" 
...
#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3" 

1 << 2 equals 4, not 3, here is where the bug is lying

TsuG.

CCTextFieldTTF do not use UTF string for ANDROID

CCTextFieldTTF* ttf = CCTextFieldTTF::textFieldWithPlaceHolder("", "American Typewrite", 30);
ttf->setString("Engํ•œ๊ธ€");

const char* txt = CCIMEDispatcher::sharedDispatcher()->getContentText();

txt is not NULL, but nativeGetContentText() return "";

how i fix that?

Android layout and cocos2dx layout

Hello,

I have tried to play a bit with cocos2d-x on Android platform, looks / works great. However, seems like there is something wrong with the layout on Android.
I have tried to add an android component over the cocos2 view, but seems like cocos2 is rotated from the Android layout, and because of this the text displayed in Android control is perpendicular to text displayed by cocos2dx.

I tracked down the code until CCDirector_mobile.cpp, where there are some rotations applied (in CCDirector::applyOrientation) depending on device orientation, and I'm wondering why they are applied.
Also, in CCDirector::getWinSize(void) seems like x,y is swapped in landscape mode.

I'm trying to figure out what is going on but I'm not sure why these transformations are applied.

I'd like to have the cocos2d in Portrait when Android layout is portrait, and in Landscape when layout is Landscape, and I'm not sure why those applied changes are there for.

CCLabelTTF text alignment ignored....

CCLabelTTF* pLabel = CCLabelTTF::labelWithString(testString->m_sString.c_str(),CCSizeMake(50,18),CCTextAlignmentRight,"Thonburi", 18);
//CCLabelTTF* pLabel = CCLabelTTF::labelWithString(testString->m_sString.c_str(),"Thonburi", 18);

Both these lines have the text in the same position...Alignment is ignored.

Test on iOS

Bug in CCArray::randomObject()?

CCObject* CCArray::randomObject()
{
if(data->num==0) return NULL;

return data->arr[(int)(data->num*CCRANDOM_0_1())];

}

if CCRANDOM_0_1() return 1,
data->num*CCRANDOM_0_1() = data->num;

index out of range?

Please avoid $(SolutionDir) in Project configuration

The project configuration uses $(SolutionDir) on several settings, which makes it impossible to add the cocos projects into own solutions.

For example, in cocos2dx, PreLinkEvent this command is used:
if not exist "$(OutDir)" mkdir "$(OutDir)"
xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries*.*" "$(OutDir)"

This could be replaced with:
if not exist "$(OutDir)" mkdir "$(OutDir)"
xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries*.*" "$(OutDir)"

The lua project uses $(SolutionDir) in it's include paths, where it can be replaced with "../../" relative paths.

This changes shouldn't affect existing projects, but should allow to add them into own visual studio solutions somewhere else on your hard disk.

CCLabelBMFont error

Hi,

When i init the CCLabelBMFont using labelWithString, it doesn't show right. I must call setString() again. I think it has some problems with init.

levelLabel = CCLabelBMFont::labelWithString("        ", "ITC_AVANT.fnt");
levelLabel->setString("LV.1AAAAAAAAAAAAAA");

You can try to change the space amount.


Problem still exists in the latest version. I must setString twice, if not it will show incorrect sometimes.

Yann

CCTextureCache::addImage ignores error in CCTexture2D::initWithImage

In CCTextureCache.cpp:446 (addImage(const char * path)) there is the following problem:

texture = new CCTexture2D();
texture->initWithImage(&image, resolution); // returns a boolean

if( texture ) // should check result of previous method call
{
    // ...
    // this is executed even if there was an error in initWithImage
    texture->release(); // double release will finally result in an error
}
else
{
    CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path);
}

And in CCTexture2D.cpp:272 (initWithImage(CCImage * uiImage, ccResolutionType resolution)):

if (imageWidth > maxTextureSize || imageHeight > maxTextureSize) 
 {
    CCLOG("cocos2d: WARNING: Image (%u x %u) is bigger than the supported %u x %u", imageWidth, imageHeight, maxTextureSize, maxTextureSize);
    this->release();
    return NULL; // should return false instead
}

Android build_native.sh clears assets directory

The assets directory will be rm -rf'ed by the build scripts. This is not acceptable since the assets directory is a common place for data files needed in the app or other components (see this report).

The comment in the script is also misleading.

# make sure assets is exist
if [ -d $HELLOWORLD_ROOT/assets ]; then
    rm -rf $HELLOWORLD_ROOT/assets
fi

mkdir $HELLOWORLD_ROOT/assets

Loading a particle plist file [lua]

We're trying to create a small demo app that uses @ciaranj's lua bindings for particleWithFile, but we can't seem to get it to load our custom particle designer plist. Here's the relevant snippet:

-- ... snip ...
local winSize = cocos2d.CCDirector:sharedDirector():getWinSize()
particleTexture = cocos2d.CCTextureCache:sharedTextureCache():addImage("particleTexture.png")
print("Particles created") 

-- This part works as expected
particleExplosion = cocos2d.CCParticleExplosion:node()
particleExplosion:setPosition(cocos2d.CCPoint(winSize.width/2,winSize.height/2))
particleExplosion:setTexture(particleTexture)
layerGame:addChild(particleExplosion)
-- End First Effect

-- This doesn't do anything
particlesBG = cocos2d.CCParticleSystem:particleWithFile("testParticles.plist")
particlesBG:setTexture(particleTexture)
particlesBG:setPosition(cocos2d.CCPoint(winSize.width/2,winSize.height/2))
layerGame:addChild(particlesBG)
-- End Second Effect

print("Particles added")
initHUD(layerGame)
cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc("hellobox2d_tick", 0.016667, false)

-- ... snip ...

Note that there are 2 particles being added to the scene there. The CCParticleExplosion works as you might expect (a colorful blast of fading particles from the center of the screen). The second particle effect is just something we spit out of the designer for test purposes. Any help would be greatly appreciated.

Thank you for your hard work!

EaseActions reverse broken

Hey,

Allmost all EaseXXX::reverse actions are broken.

The problem is that cocos2d-x is using the cocos2d-iphone pattern for the reverse. And this pattern is not valid on C++.

cocos2d-iphone code:
https://github.com/cocos2d/cocos2d-iphone/blob/gles20/cocos2d/CCActionEase.m#L130

cocos2d-x code:
https://github.com/cocos2d/cocos2d-x/blob/gles20/cocos2dx/actions/CCActionEase.cpp#L185

Basically, cocos2d calls:
[self class]... this means that the code will work for any subclass

While cocos2d-x calls:
CCEaseRateAction::... creating a EaseRateAction.

So, when the subclass of CCEaseRateAction call "reverse", instead of creating an instance of their self, it will create an instance of CCEaseRateAction.

I guess this could be fixed by:
a) Each subclass shall implement the reverse action (easier way)
b) or each subclass should implement the clone() pattern.

CCImage_Linux has bugs

initWithString gives, in the best case, badly rendered glyphs and in the worst case segfault due to memory deallocation problem...

Easy to reproduce. Just make a CCLabelTTF on linux.

Wrong directory name in linux makefiles

In CocosDenshion/proj.linux and cocos2dx/proj.linux, there are two places each where the "linux" directory is referenced as "Linux", preventing ./build-linux.sh from competing.

../platform/Linux/CCAplication_linux.o
../platform/Linux/CCEGLView_linux.o \

OBJECTS = ../Linux/FmodAudioPlayer.o
../Linux/SimpleAudioEngine.o

don't support gles2.0 error

I got the error "don't support gles2.0" using cocos2d-x rc0a and rc2 with GPU Emulation enabled and builds for versions 2.2 -> 4.1 as well as a physical android device running v2.3.7.

Googling revealed there is a bug that causes info.reqGIEsVersion to return 0 instead of 0x20000 for some reason.
Adding the condition "|| Build.FINGERPRINT.startsWith("generic"));" to detectOpenGLES20() solves the problem, but I'm not sure if this is just negating the original check or not.

import android.os.Build;
private boolean detectOpenGLES20()
{
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x20000 || Build.FINGERPRINT.startsWith("generic"));
}

Hopefully this will help anyone else who has this issue.

CCSpriteNode heirarchy

Hello,

I have a CCSpriteBatchNode, with a texture of for example the alphabet.

I'm attempting to create a simple display hierarchy in which, i can create a abstract 'wordEntity' which is added to the alphabetBatchNode, but is in reality composed of for example 5 'letterEntities'
The reason I want to do this, is because I want the 'word' transformations applied to the 'wordEntity' such as position, rotation, etc, to be applied to the 'letterEntities'

This seems like a very normal usage, and it works.
Except once I create the second entity it crashes the application.

If I do not add the second 'wordEntity' to the display hierarchy everything is fine, except of course I cannot see it.
If I add only the second letter to the display hierarchy, and not the first everything is also fine.
If add the 'letterEntity's to the alphabetBatchNode directly, everything also is fine.

So i do not believe the error i in my creation of the objects etc.
Is this a bug in Cocos2d? I've used the same methodology in a game for Cocos2D-iphone

Cannot activate C++11 with libc++

Hi, I'd like to use C++11 features but I can't find a way to compile Cocos2d x-code projects (the template ones).
I first generate the template project and then change the C++ dialect to either C++11 or gnu-C++11.

/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:69: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
        { kPVRTextureFlagTypePVRTC_2,   GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1,    2,      true, kCCTexture2DPixelFormat_PVRTC2 },
                                                                             ^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:69: note: override this message by inserting an explicit cast
        { kPVRTextureFlagTypePVRTC_2,   GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1,    2,      true, kCCTexture2DPixelFormat_PVRTC2 },
                                                                             ^~
                                                                             st)tic_cast<unsigned         int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:73: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
        { kPVRTextureFlagTypePVRTC_2,   GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1,    2,      true, kCCTexture2DPixelFormat_PVRTC2 },
                                                                                 ^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:73: note: override this message by inserting an explicit cast
        { kPVRTextureFlagTypePVRTC_2,   GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1,    2,      true, kCCTexture2DPixelFormat_PVRTC2 },
                                                                                 ^~
                                                                                 st)tic_cast<unsigned         int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:69: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
        { kPVRTextureFlagTypePVRTC_4,   GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1,    4,      true, kCCTexture2DPixelFormat_PVRTC4 },
                                                                             ^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:69: note: override this message by inserting an explicit cast
        { kPVRTextureFlagTypePVRTC_4,   GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1,    4,      true, kCCTexture2DPixelFormat_PVRTC4 },
                                                                             ^~
                                                                             st)tic_cast<unsigned         int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:73: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
        { kPVRTextureFlagTypePVRTC_4,   GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1,    4,      true, kCCTexture2DPixelFormat_PVRTC4 },
                                                                                 ^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:73: note: override this message by inserting an explicit cast
        { kPVRTextureFlagTypePVRTC_4,   GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1,    4,      true, kCCTexture2DPixelFormat_PVRTC4 },
                                                                                 ^~
                                                                                 st)tic_cast<unsigned         int>(
4 errors generated.

This is easy to fix by adding static casts.
Once done, everything compile and run.

Now if I also set the library to LLVM libc++ (that support C++11), I get this compiler error:

CompileC /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.o test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk
    setenv LANG en_US.US-ASCII
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch i386 -fmessage-length=0 -std=c++11 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-newline-eof -Wc++11-extensions -DDEBUG=1 -DCOCOS2D_DEBUG=1 -DUSE_FILE32API -DTARGET_OS_IPHONE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fexceptions -fasm-blocks -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.6 -g -fvisibility-inlines-hidden -Wno-conversion -Wno-sign-conversion -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/test_cocos2d_chipmunk.hmap -Itest_cocos2d_chipmunk/libs/Chipmunk/include/chipmunk -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Products/Debug-iphonesimulator/include -Itest_cocos2d_chipmunk/libs/cocos2dx -Itest_cocos2d_chipmunk/libs/CocosDenshion/include -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/include/libxml2 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/DerivedSources/i386 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/DerivedSources -F/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Products/Debug-iphonesimulator -include /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/PrecompiledHeaders/Prefix-flctrunwlowyjndlnuagbuekehow/Prefix.pch -MMD -MT dependencies -MF /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.d --serialize-diagnostics /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.dia -c /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp -o /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.o

In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp:32:
In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/include/CCScriptSupport.h:30:
In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/include/CCSet.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/set:338:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tree:16:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:592:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:157:8: error: no member named 'uint8_t' in the global namespace
using::uint8_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:158:8: error: no member named 'uint16_t' in the global namespace
using::uint16_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:159:8: error: no member named 'uint32_t' in the global namespace
using::uint32_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:160:8: error: no member named 'uint64_t' in the global namespace
using::uint64_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:162:8: error: no member named 'int_least8_t' in the global namespace
using::int_least8_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:163:8: error: no member named 'int_least16_t' in the global namespace
using::int_least16_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:164:8: error: no member named 'int_least32_t' in the global namespace
using::int_least32_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:165:8: error: no member named 'int_least64_t' in the global namespace
using::int_least64_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:167:8: error: no member named 'uint_least8_t' in the global namespace
using::uint_least8_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:168:8: error: no member named 'uint_least16_t' in the global namespace
using::uint_least16_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:169:8: error: no member named 'uint_least32_t' in the global namespace
using::uint_least32_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:170:8: error: no member named 'uint_least64_t' in the global namespace
using::uint_least64_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:172:8: error: no member named 'int_fast8_t' in the global namespace
using::int_fast8_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:173:8: error: no member named 'int_fast16_t' in the global namespace
using::int_fast16_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:174:8: error: no member named 'int_fast32_t' in the global namespace
using::int_fast32_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:175:8: error: no member named 'int_fast64_t' in the global namespace
using::int_fast64_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:177:8: error: no member named 'uint_fast8_t' in the global namespace
using::uint_fast8_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:178:8: error: no member named 'uint_fast16_t' in the global namespace
using::uint_fast16_t;
     ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:179:8: error: no member named 'uint_fast32_t' in the global namespace
using::uint_fast32_t;
     ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

As said I only get this problem with cocos2d-x projects, not, for example with console applications.
I hunted the problem all day without finding anything.

CCLabelTTF not working as expected in Linux

Font names like "Arial" are used throughout the project (in tests, in HelloWorld and even in cocosd2x), but CCImage class for Linux (cocos2dx/platform/linux/CCImage_linux.cpp, using FreeType2) cannot handle it.

What happens is that the font cannot be loaded, but the error is not reported by functions like CCLabelTTF::labelWithString and thus the labels will not be displayed, without notifying the application in any way.

This shows two problems. One concerns all the platform: if CCLabelTTF::labelWithString fails, the application won't be able to handle it, and everything will work normally but the labels won't be shown.

The second issue concerns Linux only: font names like "Arial" won't be loaded by FreeType2 and CCLabelTTF::labelWithString will fail.

I'll try to submit a patch for the second issue by using fontconfig to find fonts matching a given pattern (ie: Arial) or falling back on the default font if no matching font can be found.

Unable to launch Visual studio 2010 binaries (libCocosDenshion?)

I'm trying to use the build Cocos2d-x using Visual Studio 2010 but I'm getting an error message when I try to launch these binaries (happens in both Release and Debug mode):

I think the problem is related to the libCocosDenshion project. When I create a new project with Denshion included, it fails to start in the same way as the Lua example and tests. If I create a new project without Denshion, it runs just fine.

Just FYI: Under visual studio 2008 there are no problems at all (I got both compilers installed, but under 2008 intellisense isnt working that well).

Naming clash in CCTouchDispatcher.cpp

There is a problem with less() function:

static bool less(const cocos2d::CCTouchHandler *p1, const cocos2d::CCTouchHandler *p2)
{
    return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority();
}

In some circumstances (Mac OS X, XCode, order of #include's) one can get an error here (line 304):

void CCTouchDispatcher::rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray)
{
    std::sort(pArray->begin(), pArray->end(), less);
}

Probably, it is due to disambiguation with std::less, which is accessible via ADL (Koenig lookup) [1] or something like that.

Possible solution:

namespace /* [2] */ { namespace details {
    
bool less(const cocos2d::CCTouchHandler *p1, const cocos2d::CCTouchHandler *p2)
{
    return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority();
}

} }
void CCTouchDispatcher::rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray)
{
    std::sort(pArray->begin(), pArray->end(), details::less);
}

[1] http://en.wikipedia.org/wiki/Argument-dependent_name_lookup
[2] http://stackoverflow.com/questions/154469/unnamed-anonymous-namespaces-vs-static-functions

SimpleAudioEngine on blackberry

When call "resumeBackgroundMusic" (usually in applicationDidEnterForeground) it is start to play music, even previously no call of playBackgroundMusic
And resumeAllEffects causes to play sound effect, which no be played yet.

SimpleAudioEngine on Linux port

While try to play background music on linux port

SimpleAudioEngine::sharedEngine()->playBackgroundMusic("background.wav", true);

Nothing happens

But, when i play effect

 SimpleAudioEngine::sharedEngine()->playEffect("move.wav");

It's played twice

I try other sound format's and but nothing has changed.
Also I add this code before play sound

SimpleAudioEngine::sharedEngine()->preloadEffect("move.wav");
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("background.wav");

Nothing has changed too.

I compile and run same project on win32 it's work perfectly.

MySystem : Linux Mint 11 x32 (based on Ubuntu 11.04)
cocos2d : latest release from github

Proper singleton pattern for CCApplication::sharedApplication()

I was wondering why CCApplication doesn't follow the traditional singleton pattern. Currently CCApplication::sharedApplication() will result in an error if no instance exists and CCApplication() will too if an instance already exists. Is there are reason this is not implemented like the following?

static CCApplication& sharedApplication() {
    static CCApplication instance;
    return instance;
}

This would be useful when deviating from the default project setup, e.g. when integrating a cocos2d-x application into an existing Android or iOS app.

CCSprite could not be rendered after runScene in cocos2d-x qt branch

Cocos2d qt branch is a great help to write a editor.

But while i am trying to add a CCSprite after the mainLoop is running, the texture could not be rendered as normal, just a white box.

This case could be reproduced in the HelloWorld project of this branch simply by move the add HelloWorld Sprite code to the menu handler.

BTW, i have try this in the main branch, but it's ok. So i think it may be a bug of cocos2d-qt branch.

expected unqualified-id before '(' token in CCActionCamera.cpp:107

I pulled the newest version from branch master, tried to compile under windows and had these errors :

Compile++ thumb : cocos2dx_static <= CCActionCamera.cpp
F:/xxxxxxxxx/cocos2dx/actions/CCActionCamera.cpp: In member function 'virtual void cocos2d::CCOrbitCamera::startWithTarget(cocos2d::CCNode *)':
F:/xxxxxxxxx/cocos2dx/actions/CCActionCamera.cpp:107: error: expected unqualified-id before '(' token
F:/xxxxxxxxx/cocos2dx/actions/CCActionCamera.cpp:109: error: expected unqualified-id before '(' token
F:/xxxxxxxxx/cocos2dx/actions/CCActionCamera.cpp:111: error: expected unqualified-id before '(' token

I've resolved this bug by removing "std::" from "std::isnan" in those lines.

cannot find -lCocosDenshion (Blackberry)

Hi,
I found a problem that after I compile I got an error of "cannot find -lCocosDenshion" as below.

/Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/ntox86-ld: cannot find -lCocosDenshion
cc: /Developer/SDKs/bbndk-2.1.0-beta1/host/macosx/x86/usr/bin/ntox86-ld error 1
Build error occurred, build is stopped

I using bbndk-2.1.0-beta1.

Thank you.

Lam

Problem with TexParams after application comes from background in Android

I have a CCSprite node of which I set it's texture's wrap parameters to GL_CLAMP_TO_EDGE for horizontal coordinates and GL_REPEAT for the vertical coordinates. This way I show a part of the texture and have spinning effect.

Under Android platform when my application comes back from background the texture wrapping parameters are set to GL_CLAMP_TO_EDGE both and it doesn't matter if I try to set that texture's parameters during CCApplication::applicationWillEnterForeground() or CCLayer::onEnter, the texture still looks clamped to the edge.

When I set the texParams again right before I update the node it looks fine but still the artifacts are visible until I click any button to update the screen.

This behaviour is not observable under iOS.

Android, Build : Build dependencies using official tools and from source

Cocos2D-X on Android depends on the following external BINARY libraries :

  • libxml2

  • libjpeg

  • libpng

    ... also due to the current build system it automatically incorporates

  • some Crystax libraries

  • libiconv

  • unneeded portions of libjpeg in the prebuilt binaries

This needs to be fixed.

Explanation

Currently external depenencies are built using Crystax's toolchain and distributed as prebuilt binaries.
Reasons :

  1. There are no distributable makefiles in the Cocos sources for these dependencies
  2. For a long time Android did not support C++ fully
  3. It is assumed that the build time will be very long (possibly because of Android's poor build sytem)

The fix is now possible because Android NDK has

  • Better makefiles
  • Better C++ support

Suggested fix

  1. Modularize the Android NDK makefiles
  2. Add Cocos2dx/Android specific makefiles to external dependencies
  3. Fork a correct version of external depenencies to Cocos2D's github
  4. Build external dependencies from source
  5. Use standard toolchain
  6. Remove depenency on 3rd-party toolchain
  7. Prove that compile time is reasonable (so that it is possible to distribute as source)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.