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
Blender Game Engine Game Type Templates Logic Bricks (and Python script) based Game Templates for Blender

Blender-Game-Engine-Templates Blender Game Engine Game Type Templates Logic Bric

null 3 Oct 25, 2022
An all-inclusive Python framework for the Riot Games League of Legends API. We focus on making the data easy and fun to work with, while providing all the tools necessary to create a website or do data analysis.

Cassiopeia A Python adaptation of the Riot Games League of Legends API (https://developer.riotgames.com/). Cassiopeia is the sister library to Orianna

Meraki Analytics 473 Jan 7, 2023
user friendly python script who is able to catch fish in the game New World

new-world-fishing-bot release 1.1.1 click img for demonstration Download guide Click at latest release: Download and extract bot.zip: When you run fil

null 297 Jan 8, 2023
A sprite ripper and converter for Com2uS' 2007 game Music World.

Music World Sprite Dumper This repository contains a python script reads an UNCOMPRESSED Music World pxo file and attempts to dump sprites from it. Th

Buu342 1 Mar 16, 2022
Open-source project written in the ursina engine, simulating the popular game Minecraft.

Voxelcraft is an open-source project written in the ursina engine, simulating the popular game Minecraft.

Calinescu Mihai 21 Oct 6, 2022
An open source Python library for the Snake retro game.

An open source Python library for the Snake retro game.

null 3 Jul 13, 2021
Open source translation for the Tsukihime Remake game

Tsukihime-Translation Open source translation for the Tsukihime Remake game prepared by Clovermoon and Tsukihimates. Copyright Disclaimer under Sectio

null 118 Jan 1, 2023
made a life sim game because i was tired of a astray gamedev company, everything here is open-source

Srel made a life sim game because i was tired of a astray gamedev company, everything here is open-source Progress Currently making the cmd-line versi

null 2 Nov 14, 2021
Text-Adventure-Game [Open Source] A group project by the Python TASK Force

Text-Adventure-Game [Open Source] A group project by the Python TASK Force

Mircea Dumitrescu 2 Sep 17, 2021
A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

Amos 3 Aug 29, 2021
Open source Brawl Stars server emulator for version 29 of the game!

Welcome to Classic-Brawl v29 Remake ?? Open source Brawl Stars server emulator for version 29 of the game! (Remake) What's working ? Battles Trophies

CrossFire 4 Jan 19, 2022
Vitrix is an open-source FPS video game coded in python

Vitrix is an open-source FPS video game coded in python Table of contents Usage Game Server Installing Requirements Hardware Requirements Software Req

Vitrix 1 Feb 13, 2022
Python fitting assistant, cross-platform fitting tool for EVE Online

pyfa What is it? Pyfa, short for python fitting assistant, allows you to create, experiment with, and save ship fittings without being in game. Open s

null 1.4k Dec 22, 2022
A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

null 24 Dec 25, 2022
A tool for the creation of rooms used in maps in the game Wastelands

Wastelands Room Data editor A tool for the creation of rooms used in maps in the game Wastelands Creates .wrd files, that get loaded by the map genera

Avant 6 Jul 12, 2021
Mandaw 2 Mar 1, 2022
Snake game mixed with Conway's Game of Life

SnakeOfLife Snake game mixed with Conway's Game of Life The rules are the same than a normal snake game but you have to avoid cells created by Conway'

Aidan 5 May 26, 2022
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
HTTP API for FGO game data. Transform the raw game data into something a bit more manageable.

FGO game data API HTTP API for FGO game data. Transform the raw game data into something a bit more manageable. View the API documentation here: https

Atlas Academy 51 Dec 26, 2022