Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A classic Hello World label centered on the screen.
#include "HelloScene.h"
#include "cocos2d.h"
USING_NS_CC;
Scene* HelloScene::createScene() {
auto scene = Scene::create();
auto layer = HelloScene::create();
scene->addChild(layer);
return scene;
}
bool HelloScene::init() {
if (!Layer::init()) return false;
auto label = Label::createWithSystemFont("Hello, Cocos2d-x!", "Arial", 28);
label->setPosition(Director::getInstance()->getVisibleSize() / 2);
this->addChild(label);
return true;
}Cocos2d-x is a cross-platform, open-source C++ game engine optimized for 2D games, offering high performance, a lightweight architecture, scene graph system, physics, animations, particle effects, and deployment to mobile, desktop, web, and consoles.
Origin & Creator
Cocos2d-x originated from the Python-based Cocos2d project, created by Ricardo Quesada. It was later rewritten in C++ by Chukong Technologies and released in 2010 as a fast cross-platform engine for mobile.
Industrial Note
Cocos2d-x dominates the mobile 2D gaming industry in Asia, powering thousands of games in China, Japan, and Korea - especially hypercasual games, casino games, match-3 titles, and educational products requiring fast rendering.