kandi background
Explore Kits

cocos2d-x | Cocos2d-x is a suite of open-source cross-platform | Game Engine library

 by   cocos2d C++ Version: Current License: No License

 by   cocos2d C++ Version: Current License: No License

Download this library from

kandi X-RAY | cocos2d-x Summary

cocos2d-x is a C++ library typically used in Gaming, Game Engine applications. cocos2d-x has no bugs, it has no vulnerabilities and it has medium support. You can download it from GitHub.
|Win32|Others| | ----|------| [![Build status](https://ci.appveyor.com/api/projects/status/nlgirox464j6ldg5/branch/v4?svg=true)](![Build Status(https://travis-ci.org/cocos2d/cocos2d-x.svg?branch=v4)](https://travis-ci.org/cocos2d/cocos2d-x). [cocos2d-x][1] 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.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • cocos2d-x has a medium active ecosystem.
  • It has 15461 star(s) with 6964 fork(s). There are 1269 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 1371 open issues and 3526 have been closed. On average issues are closed in 494 days. There are 189 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of cocos2d-x is current.
cocos2d-x Support
Best in #Game Engine
Average in #Game Engine
cocos2d-x Support
Best in #Game Engine
Average in #Game Engine

quality kandi Quality

  • cocos2d-x has 0 bugs and 0 code smells.
cocos2d-x Quality
Best in #Game Engine
Average in #Game Engine
cocos2d-x Quality
Best in #Game Engine
Average in #Game Engine

securitySecurity

  • cocos2d-x has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • cocos2d-x code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
cocos2d-x Security
Best in #Game Engine
Average in #Game Engine
cocos2d-x Security
Best in #Game Engine
Average in #Game Engine

license License

  • cocos2d-x does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
cocos2d-x License
Best in #Game Engine
Average in #Game Engine
cocos2d-x License
Best in #Game Engine
Average in #Game Engine

buildReuse

  • cocos2d-x releases are not available. You will need to build from source code and install.
  • Installation instructions, examples and code snippets are available.
cocos2d-x Reuse
Best in #Game Engine
Average in #Game Engine
cocos2d-x Reuse
Best in #Game Engine
Average in #Game Engine
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

cocos2d-x Key Features

Fast

Free

Easy to use

Community supported

[Cocos2d-x stable versions](http://www.cocos2d-x.org/download)

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][5] and [Chipmunk][6]

Particle system

Skeleton Animations: [Spine][7] 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

cocos2d-x

copy iconCopydownload iconDownload
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

Runtime Requirements

copy iconCopydownload iconDownload
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

How to start a new game

copy iconCopydownload iconDownload
$ 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]

Trying to get user input to move sprite in Cocos2D-X

copy iconCopydownload iconDownload
float playerX = visibleSize.width / 2 + origin.x;
float playerY = visibleSize.height / 2 + origin.y;
    
auto player = Sprite::create("sprites/player.png");
if (player == nullptr)
{
    problemLoading("'sprites/player.png'");
}
else
{
    // position the sprite on the center of the screen
    player->setPosition(Vec2(playerX, playerY));

    // add the sprite as a child to this layer
    this->addChild(player, 0);
}

    // Keyboard events
auto keyboardListener = EventListenerKeyboard::create();

// add mutable specifier
keyboardListener->onKeyPressed = [playerX, playerY, player](EventKeyboard::KeyCode keyCode, Event* event) mutable
{
    switch (keyCode)
    {
    case EventKeyboard::KeyCode::KEY_W:
        playerY += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_A:
        playerX -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_S:
        playerY -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_D:
        playerX += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_ESCAPE:
        Director::getInstance()->end();
        break;
    }
    
    player->setPosition(playerX, playerY);
};
    _eventDispatcher->addEventListenerWithSceneGraphPriority(keyboardListener, this);

Cocos2d-x app code not allowing volume control buttons to work on iPhone or iPad

copy iconCopydownload iconDownload
CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("background4.mp3", true);

Which EventDispatcher to use in cocos2d ? Node::EventDispatcher or Director::EventDispatcher?

copy iconCopydownload iconDownload
_eventDispatcher = _director->getEventDispatcher(); // Check CCNode.cpp
Director::getInstance()->getEventDispatcher()->addEventListenerWith..

this->getEventDispatcher()->addEventListenerWith..

_eventDispatcher->addEventListenerWith..
_eventDispatcher = _director->getEventDispatcher(); // Check CCNode.cpp
Director::getInstance()->getEventDispatcher()->addEventListenerWith..

this->getEventDispatcher()->addEventListenerWith..

_eventDispatcher->addEventListenerWith..

Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"

copy iconCopydownload iconDownload
/* Getting the desired particleEffect position */    
const Vec2& desiredPos = testNode->getChildByName("blablablah")->getPosition();
std::string filePath = "/"; //assign a directory for the .plist

// Avoid exponentiation
if (!testNode->getChildByName("sampleParticle")) {
    auto p1 = ParticleSystemQuad::create(filePath + "/" + "test.plist");
    p1->setPosition(desiredPos);
    p1->resetSystem();
    p1->setName("sampleParticle");
    p1->setVisible(true);
    testNode->addChild(p1);
}

There is no sln file in proj.win32

copy iconCopydownload iconDownload
cd ProjectName/proj.win32
cmake ..
cd ProjectName/proj.win32
cmake ..

Community Discussions

Trending Discussions on cocos2d-x
  • Trying to get user input to move sprite in Cocos2D-X
  • Android 11 - System.loadLibrary for native C++ library takes 60+ seconds, works perfectly fast on Android 10 and below
  • Cocos2d-x v4.0 crashing in iPhone Simulator with Xcode 12, Xcode 12.1, Xcode 12.2
  • Cocos2d-x app code not allowing volume control buttons to work on iPhone or iPad
  • Which EventDispatcher to use in cocos2d ? Node::EventDispatcher or Director::EventDispatcher?
  • (Unity 2019.2) iOS build crashes 5 seconds after the application is killed by the user
  • Tiled map not rendered fully
  • Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"
  • There is no sln file in proj.win32
Trending Discussions on cocos2d-x

QUESTION

Trying to get user input to move sprite in Cocos2D-X

Asked 2021-Sep-05 at 09:28

I'm trying to make user input of WASD move a sprite around in Cocos2D-X. I'm pretty sure I'm doing everything correct but it gives me this error: expression must be a modifiable lvalue.

Here is my code (Note: I'm new to Cocos2D-X, so it might be a bit messy)

float playerX = visibleSize.width / 2 + origin.x;
float playerY = visibleSize.height / 2 + origin.y;
    
auto player = Sprite::create("sprites/player.png");
if (player == nullptr)
{
    problemLoading("'sprites/player.png'");
}
else
{
    // position the sprite on the center of the screen
    player->setPosition(Vec2(playerX, playerY));

    // add the sprite as a child to this layer
    this->addChild(player, 0);
}

    // Keyboard events
auto keyboardListener = EventListenerKeyboard::create();
keyboardListener->onKeyPressed = [playerX, playerY](EventKeyboard::KeyCode keyCode, Event* event)
{
    switch (keyCode)
    {
    case EventKeyboard::KeyCode::KEY_W:
        playerY += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_A:
        playerX -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_S:
        playerY -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_D:
        playerX += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_ESCAPE:
        Director::getInstance()->end();
        break;
    }
};
    _eventDispatcher->addEventListenerWithSceneGraphPriority(keyboardListener, this);

There is four of the error and they all point to a different playerX/Y +=/-= 5.0f

ANSWER

Answered 2021-Sep-05 at 09:28

Try to use mutable specifier(which allows lambdas body to modify the objects captured by copy, and to call their non-const member functions):

float playerX = visibleSize.width / 2 + origin.x;
float playerY = visibleSize.height / 2 + origin.y;
    
auto player = Sprite::create("sprites/player.png");
if (player == nullptr)
{
    problemLoading("'sprites/player.png'");
}
else
{
    // position the sprite on the center of the screen
    player->setPosition(Vec2(playerX, playerY));

    // add the sprite as a child to this layer
    this->addChild(player, 0);
}

    // Keyboard events
auto keyboardListener = EventListenerKeyboard::create();

// add mutable specifier
keyboardListener->onKeyPressed = [playerX, playerY, player](EventKeyboard::KeyCode keyCode, Event* event) mutable
{
    switch (keyCode)
    {
    case EventKeyboard::KeyCode::KEY_W:
        playerY += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_A:
        playerX -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_S:
        playerY -= 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_D:
        playerX += 5.0f;
        break;
    case EventKeyboard::KeyCode::KEY_ESCAPE:
        Director::getInstance()->end();
        break;
    }
    
    player->setPosition(playerX, playerY);
};
    _eventDispatcher->addEventListenerWithSceneGraphPriority(keyboardListener, this);

Source https://stackoverflow.com/questions/69061007

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install cocos2d-x

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

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with cocos2d-x
Consider Popular Game Engine Libraries
Try Top Libraries by cocos2d
Compare Game Engine Libraries with Highest Support
Compare Game Engine Libraries with Highest Quality
Compare Game Engine Libraries with Highest Security
Compare Game Engine Libraries with Permissive License
Compare Game Engine Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.