Cocos2d is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
game development framework for creating
2D games and other
graphical software for
iOS
Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
,
Android,
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
,
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
,
HarmonyOS
HarmonyOS (HMOS) ( zh, s=鸿蒙, p=Hóngméng, tr=Vast Mist) is a distributed operating system developed by Huawei for smartphones, tablet computer, tablets, smart TVs, smart watches, personal computers and other smart devices. It has a microk ...
,
OpenHarmony
OpenHarmony (OHOS, OH) is a family of open-source distributed operating systems based on HarmonyOS derived from LiteOS, donated the L0-L2 branch source code by Huawei to the OpenAtom Foundation. Similar to HarmonyOS, the open-source distrib ...
and
web platforms. It is written in
C++ and provides bindings for various programming languages, including
C++,
C#,
Lua, and
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
. The framework offers a wide range of features, including
physics
Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
,
particle systems,
skeletal animations,
tile maps, and others.
Cocos2d was first released in 2008, and was originally written in Python. It contains many branches with the best known being Cocos2d-ObjC (formerly known as Cocos2d-iPhone), Cocos2d-x, Cocos2d-JS and Cocos2d-XNA. There are also many third-party tools, editors and libraries made by the Cocos2d community, such as particle editors,
spritesheet editors,
font
In metal typesetting, a font is a particular size, weight and style of a ''typeface'', defined as the set of fonts that share an overall design.
For instance, the typeface Bauer Bodoni (shown in the figure) includes fonts " Roman" (or "regul ...
editors, and
level
Level or levels may refer to:
Engineering
*Level (optical instrument), a device used to measure true horizontal or relative heights
* Spirit level or bubble level, an instrument designed to indicate whether a surface is horizontal or vertical
*C ...
editors, like SpriteBuilder and CocoStudio.
Sprites and scenes
All versions of Cocos2d work using the basic primitive known as a
sprite. A sprite can be thought of as a simple 2D image, but can also be a container for other sprites. In Cocos2D, sprites are arranged together to form a scene, like a game level or a menu. Sprites can be manipulated in code based on events or actions or as part of animations. The sprites can be moved, rotated, scaled, have their image changed, etc.
Features
Animation
Cocos2D provides basic animation primitives that can work on sprites using a set of actions and timers. They can be chained and composed together to form more complex animations. Most Cocos2D implementations let you manipulate the size, scale, position, and other effects of the sprite. Some versions of Cocos2D let you also animate particle effects, image filtering effects via shaders (warp, ripple, etc.).
GUI
Cocos2D provides primitives to represent common GUI elements in game scenes. This includes things like text boxes, labels, menus, buttons, and other common elements.
Physics system
Many Cocos2D implementations come with support for common 2D physics engines like
Box2D and
Chipmunk
Chipmunks are small, striped rodents of subtribe Tamiina. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.
Taxonomy and systematics
Chipmunks are classified as four genera: '' ...
.
Audio
Various versions of Cocos2D have audio libraries that wrap
OpenAL
OpenAL (Open Audio Library) is a cross-platform audio application programming interface (API). It is designed for efficient rendering of multichannel three-dimensional positional audio. Its API style and conventions deliberately resemble those o ...
or other libraries to provide full audio capabilities. Features are dependent on the implementation of Cocos2D.
Scripting support
Support binding to
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
,
Lua, and other engines exist for Cocos2D. For example, Cocos2d JavaScript Binding (JSB) for
C/
C++/
Objective-C
Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style message passing (messaging) to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was ...
is the wrapper code that sits between native code and JavaScript code using
Mozilla's SpiderMonkey. With JSB, you can accelerate your development process by writing your game using easy and flexible JavaScript.
Editor support
End of life support
* SpriteBuilder: Previously known as CocosBuilder, SpriteBuilder is an IDE for Cocos2D-SpriteBuilder apps. SpriteBuilder is
free and its development was sponsored by
Apportable, who also sponsored the
free Cocos2D-SpriteBuilder, Cocos3D, and Chipmunk physics projects. It was available as a free app in the
Mac App Store
The Mac App Store (also known as the App Store) is a digital distribution platform for macOS apps, often referred to as Mac apps, created and maintained by Apple. The platform was announced on October 20, 2010, at Apple's "Back to the Mac" eve ...
. Its latest official version is 1.4. Its latest unofficial version is 1.5 which is compatible with cocos2d-objC 3.4.9. It supports Objective-C.
* CocoStudio: a
proprietary toolkit based on Cocos2d-x, containing UI Editor, Animation Editor, Scene Editor and Data Editor, together forming a complete system; the former two are tools mainly for artists while the latter are two mainly for designers. This is a
proprietary project developed by
Chukong Technologies. Its latest version is 3.10 which is compatible with cocos2d-X 3.10. It supports C++. In April 2016 it was deprecated and replaced with Cocos Creator.
Current support
*Cocos Creator, which is a
proprietary unified
game development tool
A game is a structured type of play usually undertaken for entertainment or fun, and sometimes used as an educational tool. Many games are also considered to be work (such as professional players of spectator sports or video games) or art (su ...
for Cocos2d-X. As of August 2017, it supports JavaScript and
TypeScript
TypeScript (abbreviated as TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications and transpiles to JavaScript. It is developed by Micr ...
only and does not support neither C++ nor Lua. It was based on the
free Fireball-X. C++ and Lua support for creator is under alpha-stage development since April 2017.
*SpriteBuilderX, a
free scene editor for Cocos2d-X with C++ support and runs on macOS only.
*X-Studio, a
proprietary scene editor for Cocos2d-X with Lua support and runs on Windows only.
*CCProjectGenerator: a project generator for Cocos2d-ObjC 3.5 that generates Swift or Objective-C projects for Xcode.
Supported platforms and languages
History
Cocos2d (Python)
February 2008, in the village of
Los Cocos, near
Córdoba, Argentina
Córdoba () is a city in central Argentina, in the foothills of the Punilla Valley, Sierras Chicas on the Primero River, Suquía River, about northwest of Buenos Aires. It is the capital of Córdoba Province, Argentina, Córdoba Province an ...
,
Ricardo Quesada, a game developer, and
Lucio Torre created a 2D game engine for
Python with several of their developer friends. They named it "Los Cocos" after its birthplace. A month later, the group released the version 0.1 and changed its name to "Cocos2d".
Cocos2d-iPhone
Attracted by the potential of the new
Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
App Store
An app store, also called an app marketplace or app catalog, is a type of digital distribution platform for computer software called applications, often in a mobile context. Apps provide a specific set of functions which, by definition, do not i ...
for the
iPhone
The iPhone is a line of smartphones developed and marketed by Apple that run iOS, the company's own mobile operating system. The first-generation iPhone was announced by then–Apple CEO and co-founder Steve Jobs on January 9, 2007, at ...
, Quesada rewrote Cocos2d in
Objective-C
Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style message passing (messaging) to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was ...
and in June 2008 released "Cocos2d for iPhone" v0.1, the predecessor of the later Cocos2d family.
Cocos2D-ObjC (formerly known as Cocos2D-iPhone and Cocos2D-SpriteBuilder), is maintained by Lars Birkemose.
Also, the English designer
Michael Heald designed a new logo for Cocos2d (the Cocos2d logo was previously a running coconut).
Cocos2d-x
November 2010, a developer from
China
China, officially the People's Republic of China (PRC), is a country in East Asia. With population of China, a population exceeding 1.4 billion, it is the list of countries by population (United Nations), second-most populous country after ...
named Zhe Wang branched Cocos2d-x based on Cocos2d. Cocos2d-x is also a
free engine under
MIT License
The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility.
Unl ...
, and it allows for compiling and running on multiple platforms with one code base.
In 2013, Quesada left cocos2d-iPhone and joined in cocos2d-x team. In March 2017, Quesada was laid off from the Chukong company.
In 2015, there are 4 cocos2d branches being actively maintained.
Cocos2d-x & Cocos2d-html5 is maintained and sponsored by developers at
Chukong Technologies. Chukong is also developing CocoStudio, which is a
WYSIWYG
In computing, WYSIWYG ( ), an acronym for what you see is what you get, refers to software that allows content to be edited in a form that resembles its appearance when printed or displayed as a finished product, such as a printed document, web ...
editor for Cocos2d-x and Cocos2D-html5, and a
free Cocos3d-x
fork of the Cocos3D project.
Other ports, forks, and bindings
Cocos2d has been ported into various programming languages and to all kinds of platforms. Among them there are:
* ShinyCocos, in
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
* Cocos2d-Android, in
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
for
Android
* Cocos2d-windows, in
C++ for
Windows XP
Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct successor to Windows 2000 for high-end and business users a ...
and
Windows 7
Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was Software release life cycle#Release to manufacturing (RTM), released to manufacturing on July 22, 2009, and became generally available on October 22, ...
* CocosNet, in
C# based on
Mono
* Cocos2d-javascript, in
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
for web browsers
* Cocos2d-XNA was born in cocos2d-x community for supporting
Windows Phone 7, but now it's branched to an independent project using C# and mono to run on multiple platforms. Jacob Anderson at
Totally Evil Entertainment is leading this branch.
* Cocos3d works as an extension on cocos2d-iPhone, written in Objective-C. Bill Hollings at
Brenwill Workshop Ltd is leading this branch.
* Axmol Engine is an open-source, C++ multi-platform engine designed for mobile devices, desktop, and Xbox, well-suited for 2D game development. It was launched in November 2019 as a fork of Cocos2d-x v4.0.
Games developed with cocos2d
*''
FarmVille
''FarmVille'' is a series of agriculture-simulation social network games developed and published by Zynga in 2009. It is similar to '' Happy Farm'' and ''Farm Town''. Its gameplay involves various aspects of farmland management, such as plo ...
''
*''
Plague Inc.''
*''
Geometry Dash'' (cocos2d-x)
*''
Legendary Wars''
*''
Miitomo
''Miitomo'' was a freemium social networking service, social networking mobile app developed by Nintendo for iOS and Android (operating system), Android devices. The app, Nintendo's first, allowed users to converse with friends by answering vari ...
'' (cocos2d-x)
*''
Badland'' (cocos2d-iphone)
*''
Shadow Fight 2'' (cocos2d-x)
*''
Cookie Run: OvenBreak''
*''
Fire Emblem Heroes''
*''
Magia Record''
*''
Harry Potter: Hogwarts Mystery'' (cocos creator)
*''
FlyMe2theMoon'' (cocos2d)
*''
Pokémon: Magikarp Jump''
See also
*
Starling Framework
Starling is an open source game framework used to create 2D games that run both on mobile and desktop platforms. It recreates the traditional Flash display list architecture on top of accelerated graphics hardware. Several commercial games hav ...
*
FlatBuffers
References
Further reading
*
External links
*
{{Video game engines
C Sharp libraries
Free computer libraries
Free game engines
Free software programmed in Objective-C
Free software programmed in Python
Python (programming language)-scriptable game engines
Software using the BSD license
Software using the MIT license
Video game development software