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
A cross-platform Java game Engine (Framework) , support JavaFX / Android / IOS / HTML5 / Linux / MAC / Windows

Loon Game Engine (Java Game Framework) EN / KR Free Game Resources Links Download Loon Game Engine Only Android-studio Template : androidstudio-templa

cping 502 Jan 4, 2023
This is an application that is about an X / O game. You can enter the names of the game, and there is also a screen for those who win and there is a button to continue playing and the game determines the result of each player

Game-X-O This is an application that is about an X / O game. You can enter the names of the game, and there is also a screen for those who win and the

Mohamed Rafat 2 Aug 20, 2022
An easy open source Android Native Game FrameWork.

JustWeEngine - Android Game FrameWork An easy open source Android Native Game FrameWork. Engine Flow Chart How To Use? Import Engine's module as Libra

JustWe 767 Dec 8, 2022
Simple 2D platform game.

FloreProject Simple 2D platform game. Supported platforms OS Support Android ❌ Not playable Windows ✅ Full support Linux ✅ Full support MacOS ✅ Full s

Victor Varenik 4 Jan 7, 2022
Android-application used as an introduction to Android development and Android APIs.

Android-application used as an introduction to Android development and Android APIs. This application is an implementation of the game Thirty and written in Kotlin.

Oscar Johansson 0 Nov 6, 2021
Game made with Korge (Kotlin Multiplatform game engine)

MolesAttack Kotlin Multiplatform Game Play Html/js: https://feliperce.github.io/MolesAttack-Distribution/ Jar: https://feliperce.github.io/MolesAttack

Felipe Rodrigues 10 May 30, 2022
Our maze game is an 2d-animation game developed using android studio.

Our maze game is an 2d-animation game developed using android studio. The game consists of a ball and a board with a hole in the center of it. We are using accelerometer as controller to guide ball towards the hole. T

Suraj Devgan 6 Nov 29, 2022
Desktop/Android/HTML5/iOS Java game development framework

Cross-platform Game Development Framework libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux

libgdx 20.9k Jan 8, 2023
Tic Tac Toe game using Test Driven Development

Tic Tac Toe About this Kata This short and simple Kata should be performed using Test Driven Development (TDD). Rules The rules are described below :

null 0 Oct 11, 2021
Desktop/Android/HTML5/iOS Java game development framework

Cross-platform Game Development Framework libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux

libgdx 20.9k Dec 28, 2022
OpenModInstaller is an innovative open-source application for universal Minecraft mod management.

OpenModInstaller is an innovative open-source application for universal Minecraft mod management.

OpenModInstaller 11 Dec 9, 2021
Minosoft is an open source minecraft client, written from scratch in kotlin (and java).

Minosoft Minosoft is an open source minecraft client, written from scratch in kotlin (and java). It aims to bring more functionality and stability. No

null 151 Dec 31, 2022
An open-source, mod-friendly Android+Desktop remake of Civ V, made with LibGDX

Unciv - FOSS Civ V for Android+Desktop What is this? An open-source, mod-friendly Android+Desktop remake of Civ V, made with LibGDX Is this any good?

Yair Morgenstern 4.7k Jan 5, 2023
Free Android 2D OpenGL Game Engine

AndEngine Donations While developing AndEngine was a lot of fun, it also also consumed many(!) months of my life. It actually continues to cost me a s

Nicolas Gramlich 3.2k Jan 5, 2023
QRGame - storage a game inside a qr code

QRGame Can we storage a game inside a qr code? Yes! At least in theory. That was the question that started that entire project. QRGame is an Android p

Aislan Tavares 10 Mar 13, 2022
Experimental multiplayer game

Enjoy retro games? Enjoy multiplayer games? Ever wanted to play one retro game against a different game in real time?

Super Retro Mega Wars 114 Dec 18, 2022
In-game editor for item NBT

Building Gradle - Dependency Management The GradleWrapper in included in this project. On Windows: gradlew.bat clean build On MacOS/Linux: ./gradlew

TabooLib Project 12 Dec 27, 2022
Basic template to create a game using minigdx

MiniGDX Game Template Create your first game using miniGDX by clicking the "Use this Template" button above. The game will be configured for: the JVM

MiniGDX 22 Dec 16, 2022
Android Kotlin: Matching Kitties: A Game Inspired by Cats

Android Kotlin: Matching Kitties: A Game Inspired by Cats A kotlin based Android memory game Screenshots | | | | | | | | | Viewing the App You can clo

Ryan Jandrick B. Obeles 20 Aug 1, 2022