cocos2d-x | Cocos2d-x is a suite of open-source cross-platform | Game Engine library

 by   cocos2d C++ Version: cocos2d-x-4.0 License: No License

kandi X-RAY | cocos2d-x Summary

kandi X-RAY | cocos2d-x Summary

cocos2d-x is a C++ library typically used in Gaming, Game Engine applications. cocos2d-x has no bugs, it has no vulnerabilities and it has medium support. You can download it from GitHub.

|Win32|Others| | ----|------| [Build status] Status([cocos2d-x][1] is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is based on cocos2d-iphone, but instead of using Objective-C, it uses C++. It works on iOS, Android, macOS, Windows and Linux.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              cocos2d-x has a medium active ecosystem.
              It has 17158 star(s) with 7072 fork(s). There are 1246 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1401 open issues and 3549 have been closed. On average issues are closed in 774 days. There are 197 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of cocos2d-x is cocos2d-x-4.0

            kandi-Quality Quality

              cocos2d-x has 0 bugs and 0 code smells.

            kandi-Security Security

              cocos2d-x has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              cocos2d-x code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              cocos2d-x does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              cocos2d-x releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cocos2d-x
            Get all kandi verified functions for this library.

            cocos2d-x Key Features

            No Key Features are available at this moment for cocos2d-x.

            cocos2d-x Examples and Code Snippets

            No Code Snippets are available at this moment for cocos2d-x.

            Community Discussions

            QUESTION

            Trying to get user input to move sprite in Cocos2D-X
            Asked 2021-Sep-05 at 09:28

            I'm trying to make user input of WASD move a sprite around in Cocos2D-X. I'm pretty sure I'm doing everything correct but it gives me this error: expression must be a modifiable lvalue.

            Here is my code (Note: I'm new to Cocos2D-X, so it might be a bit messy)

            ...

            ANSWER

            Answered 2021-Sep-05 at 09:28

            Try to use mutable specifier(which allows lambdas body to modify the objects captured by copy, and to call their non-const member functions):

            Source https://stackoverflow.com/questions/69061007

            QUESTION

            Android 11 - System.loadLibrary for native C++ library takes 60+ seconds, works perfectly fast on Android 10 and below
            Asked 2020-Dec-14 at 12:42

            In our game application for Android which is based on the game engine cocos2d-x, with most of the code being written in C++, we have a very strange and critical issue since Android 11:

            When the native library gets loaded in onLoadNativeLibraries it now suddenly takes 60+ seconds. Before Android 11, it all worked fine and it loaded in 0.2-3 seconds. Now when you start the game, you have a 60+ seconds gray screen.

            We already figured out that JNI_OnLoad gets called directly after the 60 second stall is over.

            Here's the code of the onLoadNativeLibraries function:

            ...

            ANSWER

            Answered 2020-Oct-29 at 18:06

            Short Answer:

            It's a bug in Android 11 fixed by google but not deployed yet.

            Meanwhile, if you don't care about calling static and thread_local variables destructors in your lib when program is exiting/library is unloaded, pass the flag -fno-c++-static-destructors to the compiler. (see long answer for a more granular solution using clang annotations)

            I used this flag on my project (not cocos2d) with no issue and lib is loading even faster than before.

            Long Answer:

            Unfortunately this is a performance regression introduced in android 11 (R) by the Google team. The issue is being tracked by google here.

            To summarize, when System.loadLibrary() is called, the system registers a destructor for each of the C++ global variables contained in the loaded library, using __cxa_atexit()

            Since Android 11 (R), the implementation of this function in android has changed:

            • In Q, __cxa_atexit uses a linked list of chunks, and calls mprotect twice on the single chunk to be modified.
            • In R, __cxa_atexit calls mprotect twice on a single contiguous array of handlers. Each array entry is 2 pointers.

            This change regressed the performance drastically when they are many C++ global variables which seems to be the case in cocos2d so libraries.

            Google has already implemented a fix https://android-review.googlesource.com/c/platform/bionic/+/1464716 but as stated in the issue:

            this won't be in Android 11 until the March QPR at the earliest, and since this isn't a security issue it won't be mandatory for OEMs to actually take that patch.

            Google Team suggests also some workarounds at the app level by removing or skipping the destructors on global variables:

            • For a particular global variable, the [[clang::no_destroy]] attribute skips the destructor call.
            • Pass -fno-c++-static-destructors to the compiler to skip the destructors for all static variables. This flag also skips destructors for thread_local variables. If there are thread_local variables with important destructors, those can be annotated with [[clang::always_destroy]] to override the compiler flag.
            • Pass -Wexit-time-destructors to the compiler to make it warn on every instance of an exit-time destructor, to highlight where the __cxa_atexit registrations are coming from.

            Source https://stackoverflow.com/questions/64576236

            QUESTION

            Cocos2d-x v4.0 crashing in iPhone Simulator with Xcode 12, Xcode 12.1, Xcode 12.2
            Asked 2020-Nov-20 at 22:25

            Cocos2d-x v4.0 crashing in all iPhone Simulator. In device no crash

            ...

            ANSWER

            Answered 2020-Nov-20 at 22:25

            With that little info we can't help much. But if I try to interpret the posted image corretly you receive a "EXC_BAD_ACCESS" Exception.

            This means more or less that you access a freed memory region or in general you try dereference a pointer pointing to an invalid memory address.

            The only argument which could cause such an error is source.c_str(). So you should check the code path of source.

            In release builds you don't see always "access-after-free" because memory is not immediately released to the OS (which triggers such errors) it is just marked as "free" to allow faster allocations.

            Source https://stackoverflow.com/questions/62568936

            QUESTION

            Cocos2d-x app code not allowing volume control buttons to work on iPhone or iPad
            Asked 2020-May-25 at 18:53

            I cannot confirm whether this has been since a newer iOS version (perhaps 11 onwards) but the hardware volume buttons do not respond whilst using an app I am updating at present. It uses SimpleAudioEngine and whilst I have looked at some other projects I have that use Cocos2d-x, I have tried to use the SimpleAudioEngine source from there, with zero success.

            The version of cocos2d-x is v2.1.1

            In my HelloWorldScene.cpp I am calling

            ...

            ANSWER

            Answered 2020-May-25 at 18:53

            In most of my apps i use the same syntax and it is working using cocos2d-x version 3.17.2.

            Source https://stackoverflow.com/questions/61787063

            QUESTION

            Which EventDispatcher to use in cocos2d ? Node::EventDispatcher or Director::EventDispatcher?
            Asked 2020-Apr-29 at 18:05

            Which EventDispatcher to use in cocos2d ? Node::EventDispatcher or Director::EventDispatcher ? After referencing the official documentation of both Director class and Node class Director Class Reference Cocos2d-x Node Class Reference Cocos2d-x I am a bit confused about, what is the difference between using

            ...

            ANSWER

            Answered 2020-Apr-29 at 18:05

            Both are same. this->getEventDispatcher() calls CCNode's getEventDispatcher() function. It returns _eventDispatcher.

            Source https://stackoverflow.com/questions/61487108

            QUESTION

            (Unity 2019.2) iOS build crashes 5 seconds after the application is killed by the user
            Asked 2020-Apr-27 at 15:59
            Description

            The application presents a crash 2~5 seconds after it's terminated by the user (i.e. force kill the app). This happens only on iOS builds on multiple unity versions (see details below). Most of the crashes reports are not arriving on Crashlytics. There are very few crashes on the console, even though we're consistently reproducing this error on a daily basis. The Android builds don't present the same error.

            Steps to reproduce
            1. Open the game
            2. Wait until the loading scene is about to finish or until the game scene is fully loaded
            3. Kill the application
            4. Wait 2~5 seconds and see the crash report window
            • Reproduction rate: 80%
            • Devices used to test: iPhone SE, iPhone 7, iPhone 8, iPad Mini 4
            • Also observed the crash on: iPhone XS, iPhone XR
            Additional information
            • The issue is iOS specific. We have the same build on Android working without issues.
            • Crash reports are not being captured by Crashlytics on most cases (see some of the crashes below).
            • Crashes happen only on the final steps of the loading, where the external SDKs are being initialized.
            • On TestFlight, the crash count is 0 for almost all builds, including the ones the users are reporting the crashes.
            • Using a debug button that calls the Application.Quit() method of Unity doesn't cause the application to crash, even though it takes a while to close.
            • The crash seems to be invariante to OS version and iOS device.
            Technical information Explorations

            Here's a list of all solution attempts without success so far:

            • Remove GameAnalytics plugin
            • Remove IronSource plugin
            • Remove UnityIAP plugin
            • Workaround on PostProcess iOS
            • Set minimum OS version to 9.0
            • Comment all OnApplicationPause/Quit implementations (plugins included)
            • Enable Bitcode
            ...

            ANSWER

            Answered 2020-Apr-27 at 15:59
            Solution

            Description: The general problem is to have any piece of code that blocks the Main Thread on iOS when the application is finalizing (see this document for more information). In our case it is happening because of ongoing requests when the player kills the application. As we save the player progress on the server when the application is terminated (using Dispose() method), the request blocked the main thread, causing the crash. The solution is to remove this particular save. We tested a build including this fix and, so far, we have no crashes on 20 attempts of killing the game after the Game Scene is loaded. We haven't thought about this before because this piece of code is there since August of 2019 and it hasn't been touched since then. The problem started to happen only in February of 2020.

            More information: Since the piece of problematic code was in the project since August of 2019 and the problem started to happen only on February of 2020, it's possible that the iOS version has something to do with it. We haven't investigate the changelog yet, but the oldest iOS version presenting the crash so far is iOS 13.2, released on October 28th, 2019.

            Another possibility is that some change on our backend code caused the request to hang. As we use BestHTTP, by default all requests are aborted when the application is terminated. We haven't investigate if the execution order of Dispose vs. OnDisable/OnApplicationQuit can be the issue. Also, by default, the requests aborted by BestHTTP during Application Quit still call the callbacks. In our case, the callback for that Save Player is null, so this might not be the problem.

            Related crashes: We're still facing some crashes on the loading scene. As far as we've seen, they happen when there's a request going on. The reproduction rate of those issues are way lower than the problem on Game Scene.

            Hints: We had difficulty to retrieve the logs on Crashlytics, because most of them weren't being send. Here's a step-by-step of how to retrieve the log from the iOS device itself:

            1. Open the Settings app on your iPhone/iPad device
            2. Go to Privacy (appears below Battery on iOS 13)
            3. Scroll to the bottom and open Analytics & Improvements
            4. Open Analytics Data
            5. Find the logs for the desired application

            Source https://stackoverflow.com/questions/61435165

            QUESTION

            Tiled map not rendered fully
            Asked 2020-Mar-29 at 09:40

            I'm using cocos2d-x 3.17. When I run a Follow action on a sprite, the tiled map can't render fully. The map looks exactly the same as the screen record shows in posts below

            https://discuss.cocos2d-x.org/t/1-5b2-tiled-map-not-rendered-fully/36661

            https://discuss.cocos2d-x.org/t/solved-tilemap-rotation-clipping/37114

            But they were using Cocos Creator and can fix it by setting ENABLE_TILEDMAP_CULLING = false.

            Is there any equivalent settings in C++ api?

            ...

            ANSWER

            Answered 2020-Mar-29 at 09:40

            Found out the root cause is that the Scene has been moved by Follow action. It seems in cocos2d-x, Scene is not supposed to move.

            Source https://stackoverflow.com/questions/60867779

            QUESTION

            Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"
            Asked 2020-Feb-11 at 21:09

            I am trying to load particle effects (in .plist format) in my Cocos2d-x game code, and I am facing the warning: "libpng warning: iCCP: known incorrect sRGB profile", as mentioned in the question. I have done some research on my end, and the other StackOverflow users who asked similar questions had this issue while loading .png files.

            However, I am facing the same issue while initializing .plist files instead. Any insight on how to remove this warning would be helpful. Kindly note that I am not facing any issue with loading the .plist file as such, but the warnings are polluting my log streams.

            Sample code:

            ...

            ANSWER

            Answered 2020-Feb-11 at 21:09

            I was able to solve this by using a sub-class of ParticleSystem instead of ParticleSystem itself. The sub-class I used is ParticleSystemQuad. Additionally, I realized that the initWithFile API was being called multiple times in my code, due to Cocos2D update schedulers. That may have been a cause for this warning.

            To fix this warning, I created a fresh variable/system, and assigned a parent to it, while setting the position of the new variable to that of a well-known (desired position) node.

            Source https://stackoverflow.com/questions/59932421

            QUESTION

            There is no sln file in proj.win32
            Asked 2020-Jan-11 at 14:25

            I just installed cocos2d-x and created a new project using this command line : cocos new ProjectName -l cpp. It created with no errors but when i check proj.win32 folder, there was no .sln file. How can I open up this project? Or why there is no sln file?

            Here is what proj.win32 folder looks like:

            ...

            ANSWER

            Answered 2020-Jan-11 at 14:25

            You did it correctly. There is no .sln file just from creating a new project.

            Since you want .sln file, it means you want to use an IDE. As noted in https://github.com/cocos2d/cocos2d-x#using-ide, cmake is required in order to use IDE.

            If you don't have cmake installed, download it from https://cmake.org/download/

            After you have it installed, go to the proj.win32:

            Source https://stackoverflow.com/questions/59614832

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install cocos2d-x

            Mac OS X 10.7+, Xcode 8+. or Ubuntu 14.04+, CMake 3.1+. or Windows 7+, VS 2015. Python 2.7.5+(NOT Python 3). NDK r16+ is required to build Android games. Android Studio 3.0.0+ to build Android games(tested with 3.0.0). JRE or JDK 1.6+ is required for web publishing.
            Mac OS X 10.7+, Xcode 8+
            or Ubuntu 14.04+, CMake 3.1+
            or Windows 7+, VS 2015
            Python 2.7.5+(NOT Python 3)
            NDK r16+ is required to build Android games
            Android Studio 3.0.0+ to build Android games(tested with 3.0.0)
            JRE or JDK 1.6+ is required for web publishing

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/cocos2d/cocos2d-x.git

          • CLI

            gh repo clone cocos2d/cocos2d-x

          • sshUrl

            git@github.com:cocos2d/cocos2d-x.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link