Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

Overview

cocos2d-x

Win32 Others
Build status Build Status

cocos2d-x 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.

Cocos2d-x Framework Architecture:

cocos2d-x is:

  • Fast
  • Free
  • Easy to use
  • Community supported

Git user attention

  1. Clone the repo from GitHub.

      $ git clone https://github.com/cocos2d/cocos2d-x.git
    
  2. After cloning the repo, please execute download-deps.py to download and install dependencies.

      $ cd cocos2d-x
      cocos2d-x $ python download-deps.py
    
  3. After running download-deps.py.

      cocos2d-x $ git submodule update --init
    

Download stable versions

Documentations and samples

Main features

  • Scene management (workflow)
  • Transitions between scenes
  • Sprites and Sprite Sheets
  • Effects: Lens, Ripple, Waves, Liquid, etc.
  • Actions (behaviours):
    • Transformation Actions: Move, Rotate, Scale, Fade, Tint, etc.
    • Composable actions: Sequence, Spawn, Repeat, Reverse
    • Ease Actions: Exp, Sin, Cubic, Elastic, etc.
    • Misc actions: CallFunc, OrbitCamera, Follow, Tween
  • Basic menus and buttons
  • Integrated with physics engines: Box2d and Chipmunk
  • Particle system
  • Skeleton Animations: Spine and Armature support
  • Fonts:
    • Fast font rendering using Fixed and Variable width fonts
    • Support for .ttf fonts
  • Tile Map support: Orthogonal, Isometric and Hexagonal
  • Parallax scrolling
  • Motion Streak
  • Render To Texture
  • Touch/Accelerometer on mobile devices
  • Touch/Mouse/Keyboard on desktop
  • Sound Engine support
  • Integrated Slow motion/Fast forward
  • Fast and compressed textures: PVR compressed and uncompressed textures, ETC1 compressed textures, and more
  • Resolution Independent
  • Language: C++, with Lua and JavaScript bindings
  • Open Source Commercial Friendly(MIT): Compatible with open and closed source projects
  • OpenGL ES 2.0 (mobile) / OpenGL 2.1 (desktop) / metal(macos and iOS) based

Build Requirements

  • 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

Runtime Requirements

  • iOS 8.0+ for iPhone / iPad games
  • Android 3.0.0+ for Android
  • OS X v10.9+ for Mac games
  • Windows 7+ for Win games

Environment Setup

Should set up environment before starting a new game or running tests

$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE

Should invoke this script if using linux system

$ cd cocos2d-x
$ ./install-linux-deps.sh

Running Tests

$ cd cocos2d-x
$ mkdir build
$ cd build
$ cocos run --proj-dir .. -p [mac|win32|android|linux|ios]

How to start a new game

$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
$ cd NEW_PROJECTS_DIR/MyGame
$ mkdir build
$ cd build
$ cocos run --proj-dir .. -p [mac|win32|android|linux|ios]

You can also create a Lua project with -l lua.

Using IDE

If need to debug program, then it is more convinent to use IDE to run and debug it. All platforms other than Android can use CMake to generate corresponding project file. Can refer to Detail CMake Guide for detail information.

For Android, the Android Studio project file lies in PROJECT_DIR/proj.android. Can just use Android Studio to import the exsting project file.

Learning Resources

Spreading the word!

You can help us spread the word about cocos2d-x! We would surely appreciate it!

  • Talk about us on Facebook! Our Facebook Page
  • Tweet, Tweet! Our Twitter
  • Read our Blog and promote it on your social media.

Where to get help

Contributing to the Project

Cocos2d-x is licensed under the MIT License. We welcome participation!

Did you find a bug? Do you have feature request? Do you want to merge a feature?

Contact us

Want an awesome editor?

Cocos Creator is the new generation of Cocos game engine with a full featured editor and content creation friendly workflow. It supports all major platforms allowing games to be quickly released for the web, iOS, Android, Windows, Mac, and various mini-game platforms. A pure JavaScript-developed engine runtime is available on the web and mini-game platforms for better performance and smaller packages. On other native platforms, C++ is used to implement the underlying framework, providing greater operational efficiency. The engine is completely open source, and retains the advantages of Cocos2d-x which includes high performance, customizability, ease for debugging, easy to learn, and small package size.

Comments
  • [big refactoring] Audio latency fix for Android. Support to preload effects on Android now.

    [big refactoring] Audio latency fix for Android. Support to preload effects on Android now.

    PLEASE DONT MERGE BEFORE DEVELOPERS TEST IT. AND MORE COMMENTS NEED TO BE ADDED.

    This Pull Request has done the following things:

    • Supports to preload small audio files and cache them with PCM data buffer
    • MP3/Ogg/... files are decoded to PCM data by OpenSLES API
    • Decoded PCM buffer data matches the best sample rate & buffer size in frames of device by using resampling source code in Android Source (Android 6.0, platform/frameworks/av)
    • Big refactoring for the implementation of AudioEngineImpl for Android, better class responsibility
    • Mixing audio clips by ourself, in this way, we only need a single OpenSLES AudioPlayer for playing many clips and this will fix latency of making a AudioPlayer active and play a track. For now, we only support 32 audio clips being played simultaneously. But AudioEngine module has limited it to 24 clips by default.
    • Adds audio performance test case
    • Supports to preload audio files asynchronously.

    Please help to test it on the Android devices which have low performance. Thanks :)

    platform:android 
    opened by dumganhar 206
  • Android rendering performance issue

    Android rendering performance issue

    Some developers report there is performance issue on Android, specially on Android 6.0 + QHD devices. There are also many tickets in forum reporting about it: http://discuss.cocos2d-x.org/t/cocos2d-x-and-poor-updates/29296.

    critical platform:android 
    opened by minggo 200
  • CCEAGLView:setMarkedText problem in iOS13

    CCEAGLView:setMarkedText problem in iOS13

    • cocos2d-x version: 3.12
    • devices test on: iPhone
    • developing environments
      • NDK version:
      • Xcode version:
      • VS version:
      • browser type and version:

    Steps to Reproduce: input Chinese in TextField just recieve one charactor in setMarketedText , input number or English both ok.

    opened by lxhhuangjin 87
  • CCLabelTTF - sometimes rendering as black boxes on Android

    CCLabelTTF - sometimes rendering as black boxes on Android

    Note

    This issue is migrated from here. It was created at 2014/01/10 20:00:25 +0000

    Description

    From time to time, if I exit my game on Android while text is being displayed with CCLabelTTF, then when I re-enter the game, the text is replaced with black boxes. I’m guessing the texture is getting lost. All other textures are fine though.

    Another way to reproduce the issue:

    start game

    launch some activity (such as an interstitial ad)

    close that activity and return to game

    at this point, have CCLabelTTF display some text ==> here the text is just black boxes

    Also, here’s a related forum post in which more than one developer have experienced this issue: http://cocos2d-x.org/forums/6/topics/42500

    Comments

    • Sheado added comment: Ok,

    After tinkering I found the cause of the problem. I was preparing my CCLabelTTF in applicationWillEnterForeground(). Simply moving the code to a runAction(…callfunc…) fixes the problem.

    I don’t know if this is a bug or if the documentation just needs to be updated to warn people that they should schedule the work to be done on resuming the application.

    • wollf added comment: Problem exists with new Label::createFromTTF. If i create a label label like so: Label::createWithTTF(fontBig,"Example ttf text",TextHAlignment::RIGHT); I hide app to background (pressing HOME button) and when i re-enter it i get "white boxes". normal label: before after re-entering: after

    I think this is caused by not reloading ttfConfig created resources in reloadAllTextures. This is bad and must be fixed, though i can't deal with this myself :( Tested Device: Google Nexus 7(2013)

    • yaxinhoo added comment: @Sheado i got the same , does it fixed?
    • WenHai added comment: Hi guys,which version of Cocos2d-x are you using?
    type:bug critical 
    opened by minggo 70
  • Experimental::AudioPlayer stopped playing sounds after 10 min of game play

    Experimental::AudioPlayer stopped playing sounds after 10 min of game play

    After around 10 min of playing on my game the AudioPlayer stopped playing the audio and start giving me this message on play2d .

    cocos2d::experimental::AudioPlayer::play2d(cocos2d::experimental::AudioCache *):alGenBuffers error code:a003 I tried to clear the cash and re cash on replacing the scenes and it did't fix it . i tried to

    experimental::AudioEngine::end(); But the game crash .

    platform:ios 
    opened by Kotaiba 56
  • Cmake linux mac fixes

    Cmake linux mac fixes

    This should fix 3 issue with my previous path for cmake build system.

    • Compile errors in MacOS X 10.8 (yes too old, but forum post show that exists people that use it)
    • Link with static libraries determined with pkg-config --static --libs not works on almost any Linux distros. So do not try to do it ever. (Someone who needs fully static build on linux, can improve prebuilt libs in external).
    • FindFontconfig.cmake failed to find library on centos, because check FONTCONFIG_INCLUDE_DIRS, but on centos pkg-config returns empty include dirs, because package in standard search location for compiler.

    All this fixed now. And tested, but not against current state. Because after commit: Merge pull request #9193 from pipu/v3_flatbuffers build fully broken as folder external not contains source code for flatbuffers (

    opened by vovkasm 54
  • iPhone 6 and 6 Plus resolution issues

    iPhone 6 and 6 Plus resolution issues

    Using iPhone 6 and 6 Plus, we do not return the proper resolution for those devices.

    The proper resolutions are here: http://www.iosres.com

    Justin thinks that the UIView is returning a scale factor of 2 instead of 3, but I haven't been able to test this quite yet.

    Also, even doing something like:

    glGetIntegerv(GL_VIEWPORT,m_viewport);
    

    returns the wrong values.

    Forum thread: http://discuss.cocos2d-x.org/t/iphone-6-and-iphone-6-plus-resolution-issues/17409

    highlight 
    opened by slackmoehrle 54
  • closed #4150: fix physics position and rotation bug.

    closed #4150: fix physics position and rotation bug.

    1. Fix the bug if a node has a parent, it's physics body position is incorrect.
    2. Set anchor point to middle when invoke Node::setPhysicsBody
    3. Add PhysicsBody set/getPosition/RotationOffset method.
    4. Add PhysicsPositionRotationTest.
    opened by boyu0 53
  • new android project crash in android 5.0.2 device (Nexus 7) when use 3.12

    new android project crash in android 5.0.2 device (Nexus 7) when use 3.12

    This is the process to see this bug:

    1. cocos new test_project -p com.test.test -l cpp
    2. cd test_project
    3. python /Users/jun/Code/cocos2d-x-3.12/tools/cocos2d-console/bin/cocos.py  compile -p android --android-studio --ap android-15 --ndk-mode release --mode release  --output-dir .
    4. adb install test_project-release-signed.apk
    

    When run this test app in android 5.0.2 device (Nexus 7) , it will crash! but in android 4.4 and android 6.0, it was no problem.

    The ndk version is r11c

    type:bug critical platform:android 
    opened by boyjunqiang 52
  • Radial Gradient Layer

    Radial Gradient Layer

    Hello,

    I'm looking for a RadialGradientLayer for cocos2d-x. Discussion started here http://discuss.cocos2d-x.org/t/radial-gradient/26602/6

    I don't know OpenGL and shaders, so I can't implement it in any way. Really looking for solution from cocos2d-x developers.

    Some helpful links from thread: https://github.com/saeedafshari/ShaderLayer https://github.com/SFML/SFML/wiki/Source:-Radial-Gradient-Shader

    Can this feature be added to cocos2d-x? I believe this should be easy to implement for cocos2d-x developers..

    type:request 
    opened by Volodymyr-13 50
  • cocos compile run -p android no longer works after Android SDK update

    cocos compile run -p android no longer works after Android SDK update

    Just updated Android SDK tools to the latest version 25.3.1 and now tools/android.bat no longer works, it reports:

    The "android" command is no longer available.
    For manual SDK and AVD management, please use Android Studio.
    For command-line tools, use
    tools\bin\sdkmanager.bat and tools\bin\avdmanager.bat
    Error running command, return code: 1.
    
    • cocos2d-x version: 3.14

    Steps to Reproduce:

    1. Update android SDK to the latest versions
    2. Launch android app build compile compile -p android or compile run -p android
    opened by dmrdev 49
  • fix the bug that ect1 texture lost on android

    fix the bug that ect1 texture lost on android

    • cocos2d-x version:3.9
    • devices test on:android
    • developing environments
      • NDK version:
      • Xcode version:
      • VS version:
      • browser type and version:

    Steps to Reproduce:

    #17278 not fix the bug // etc1 support check whether alpha texture exists & load it auto alphaFile = vt->_fileName + TextureCache::getETC1AlphaFileSuffix(); Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
    reloadTexture(vt->_texture->getAlphaTexture(), alphaFile, vt->_pixelFormat);

    //After reload alphaTexture, you should setAlphaTexture,Like: vt->_texture->setAlphaTexture(vt->_texture->getAlphaTexture());

    //otherwise,ect1 texture will lost still

    opened by Canon0223 0
  • Crash in cocos2dx game 3.17.2

    Crash in cocos2dx game 3.17.2

    • cocos2d-x version: 3.17.2
    • devices test on android
    • developing environments - Android - CMake

    hello everyone if anyone knows how to sort out this crash kindly let me know.

    Steps to Reproduce:

    android.app.ApplicationPackageManager$2.onChecksumsReady ApplicationPackageManager.java line 949 Fatal Exception: java.lang.AbstractMethodError: abstract method "void android.content.pm.PackageManager$OnChecksumsReadyListener.onChecksumsReady(java.util.List)" at android.app.ApplicationPackageManager$2.onChecksumsReady(ApplicationPackageManager.java:949) at android.content.pm.IOnChecksumsReadyListener$Stub.onTransact(IOnChecksumsReadyListener.java:87) at android.os.Binder.execTransactInternal(Binder.java:1184) at android.os.Binder.execTransact(Binder.java:1143)

    opened by ashK7 1
  • cocos定时器的问题

    cocos定时器的问题

    • cocos2d-x version: 3.x release版本 (貌似4.x也一样)
    • 可能存在问题:如果一个定时器,处理的事情的函数,占用时间超过定时器时间间隔,会导致这个定时器一直处在循环处理事件中,其它定时器没有机会处理事件。 一般来说,客户端的定时器,我们不会太依赖它的时间精度,所以,建议把Timer::update里的while循环去掉!
    opened by xiaoniu1235 0
  • cocos2d-x-4 linking error when integrating with libchipmunk on linux,How to compile libchipmunk source code?

    cocos2d-x-4 linking error when integrating with libchipmunk on linux,How to compile libchipmunk source code?

    • cocos2d-x version: cocos2d-x-4
    • devices test on: ubuntu20.04
    • developing environments
      • NDK version
      • Xcode version:
      • VS version:
      • browser type and version:

    Steps to Reproduce:

    1. cd cocos-2d-x-root/
    2. mkdir -p build/linux-build
    3. make ../..
    4. make -j 4 error : linking error when integrating with libchipmunk.a

    I want to cross-compile the libchipmunk source code, Specific steps? I would like to compile libchiomunk for specific steps? Thanks you !

    opened by Sickyour 1
  • Default NDK no longer supported for Google Play Store uploads.

    Default NDK no longer supported for Google Play Store uploads.

    It would seem that as it is, this engine can no longer be used to build games which can be published on the Google Play Store.

    As of November 2022 Google Play Store uploads require Android 12 ( API level 31 ) as a minimum target API level.

    Android 12's minimum required NDK version is now NDK r23 (NDK 23.0.7599858)

    Steps I took to fix:

    1. Download a compatible NDK ( I used NDK 23.0.7599858 )
    2. Remove ndk.dir= from local.properties file
    3. Add ndkVersion = "23.2.8568313" to project level build.gradle file
    4. Add implementation 'androidx.work:work-runtime-ktx:2.7.0' to project level build.gradle dependencies
    opened by Josh1603 5
Open-source, cross-platform, C++ game engine for creating 2D/3D games.

GamePlay v3.0.0 GamePlay is an open-source, cross-platform, C++ game framework/engine for creating 2D/3D mobile and desktop games. Website Wiki API De

gameplay3d 3.9k Jan 2, 2023
ZBar Bar Code Reader is an open source software suite for reading bar codes from various sources

ZBar Bar Code Reader is an open source software suite for reading bar codes from various sources

null 2.4k Dec 26, 2022
The fastest tools for 3dtiles convert in the world!

English | 简体中文 Introduction Tools for 3D-Tiles convertion. This is a RUST language project with cpp lib to handle osgb data. Tools provided are as fol

null 1.4k Dec 30, 2022
Open source Altium Database Library with over 147,000 high quality components and full 3d models.

Open source Altium Database Library with over 147,000 high quality components and full 3d models.

Mark 1.4k Dec 29, 2022
Dust3D is a cross-platform open-source 3D modeling software

Dust3D is a cross-platform open-source 3D modeling software. Auto UV unwrapping, auto rigging with PBR Material support, pose and motion authoring all in one.

Jeremy HU 2.5k Dec 30, 2022
Metal-cpp is a low-overhead C++ interface for Metal that helps developers add Metal functionality to graphics apps, games, and game engines that are written in C++.

About metal-cpp is a low overhead and header only C++ interface for Metal that helps developers add Metal functionality to graphics applications that

Бранимир Караџић 164 Dec 31, 2022
OpenCorr is an open source C++ library for development of 2D, 3D/stereo, and volumetric digital image correlation

OpenCorr OpenCorr is an open source C++ library for development of 2D, 3D/stereo, and volumetric digital image correlation. It aims to provide a devel

Zhenyu Jiang 66 Jan 6, 2023
The DirectX Shader Compiler project includes a compiler and related tools used to compile High-Level Shader Language (HLSL) programs into DirectX Intermediate Language (DXIL) representation

DirectX Shader Compiler The DirectX Shader Compiler project includes a compiler and related tools used to compile High-Level Shader Language (HLSL) pr

Microsoft 2.4k Jan 3, 2023
Cross-platform 2D and 3D game engine.

Urho3D Urho3D is a free lightweight, cross-platform 2D and 3D game engine implemented in C++ and released under the MIT license. Greatly inspired by O

null 4.2k Jan 4, 2023
Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform AAA Open 3D Engine

Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform 3D engine that enables developers and content creators to build AAA games, cinema-quality 3D worlds, and high-fidelity simulations without any fees or commercial obligations.

O3DE 5.8k Jan 7, 2023
A completely free, open-source, 2D game engine built on proven torque technology.

Torque2D 4.0 Early Access 1 MIT Licensed Open Source version of Torque2D from GarageGames. Maintained by the Torque Game Engines team and contribution

Torque Game Engines 692 Jan 9, 2023
OpenGL®-Starter is a template for your upcoming OpenGL Projects which has been compiled to run the most basic Hello World OpenGL Program from LearnOpenGL.com.

OpenGL®-Starter OpenGL®-Starter is a template for your upcoming OpenGL Projects which has been compiled to run the most basic Hello World OpenGL Progr

Kushagra 9 Sep 7, 2022
This Project Implement an interactive camera for 3D model using Quaternion. It have some advantages over eulerian camera like no gimbal lock and faster to compute.

Quaternion-Camera This Project Implement an interactive camera for 3D model using Quaternion. It have some advantages over eulerian camera like no gim

Phan Sang 8 Nov 10, 2022
NVRHI (NVIDIA Rendering Hardware Interface) is a library that implements a common abstraction layer over multiple graphics APIs

NVRHI Introduction NVRHI (NVIDIA Rendering Hardware Interface) is a library that implements a common abstraction layer over multiple graphics APIs (GA

NVIDIA GameWorks 445 Jan 3, 2023
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

bgfx - Cross-platform rendering library GitHub Discussions Discord Chat What is it? Cross-platform, graphics API agnostic, "Bring Your Own Engine/Fram

Бранимир Караџић 12.6k Jan 8, 2023
A modern cross-platform low-level graphics library and rendering framework

Diligent Engine A Modern Cross-Platform Low-Level 3D Graphics Library Diligent Engine is a lightweight cross-platform graphics API abstraction library

Diligent Graphics 2.6k Dec 30, 2022
Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.

RetroArch RetroArch is the reference frontend for the libretro API. Popular examples of implementations for this API includes video game system emulat

null 7.4k Dec 30, 2022
Gearcoleco is a cross-platform ColecoVision emulator written in C++.

This is an open source project with its ongoing development made possible thanks to the support by these awesome backers.

Ignacio Sanchez Gines 41 Nov 12, 2022
A small cross-platform graphics library made in C

minigfx Small graphics library made in C Intended to be: Simple to understand Intuitive Fun to use Features Cross platform: Windows and Linux. To see

Laurentino Luna 27 Jul 18, 2021