cocos2d-x is a cross plaform port of cocos2d-iphone using C++. It supports iOS, Mac, Android, Samsung Bada, BlackBerry Tablet OS, Windows and Linux. It has built-in bindings for Lua and Javascript.

learn more… | top users | synonyms

1
vote
1answer
696 views

Cocos2dx+Chipmunk: Fully elastic collision between moving bodies

I'm using Cocos2dx and the built in Chipmunk physics engine, and currently I've got my PhysicsBodys' materials set up with: Density=0 Restitution=1 Friction=0 in order to get fully elastic ...
1
vote
2answers
2k views

How do I create a message box that fires a callback on button press?

I need to create a message box with an "OK"-button. When the user touches the button, it should execute a callback. I'm new to this and couldn't find any articles in the docs.
0
votes
1answer
90 views

Cocos2d background sound not playing a second time C++

I'm using cocos2d-x on windows10 UWP project. I use the SimpleAudioEngine to load the music: CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("level_music1.wav",true); On the ...
1
vote
1answer
486 views

Why current scene in cocos2dx has no children when accessed from outside scene class?

I want to access a sprite in a scene, but I cannot get the running scene from outside the scene class. The scene is created using: Scene* MyScene::createScene() { auto scene = Scene::create(); ...
1
vote
2answers
507 views

Should I draw directly on a CCLayer or a CCSprite?

Now I am a little confused in my cocos2d-x cpp project. I want to draw lines with user's finger touch. Following the screenshot of a CCScene: In the screen, there are two squares. I want show an ...
1
vote
1answer
385 views

Cocos2d/Cocos2d-x Attaching an arrow (sprite) to another body sprite (person)

I am trying to set up a simple bow and arrow game. When the arrow hits the enemy body, the arrow's body is deleted and the arrow sprite continues to update, keeping the position correct in relation to ...
1
vote
1answer
55 views

Shooting Projectiles

I am using cocos2D-x and am trying to achieve the effect of enemies going past and shooting projectiles at the player who is moving around the screen. I am using the code below, which is based on this ...
1
vote
1answer
180 views

How can i get object from TMXTiledMap and store it in Dictionary variable ?

I've been following a tutorial to make tiled map in cocos2d x 3.0 , but i couldnt complete the rest of the tutorial because its for coco2d x 2.0 version, How can i get a value of property that is ...
3
votes
1answer
68 views

How to make expanding ring with constant thickness?

I need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was thinking of scaling the image but that didnt work out because the line or ...
0
votes
0answers
23 views

How to export cocos2d-x game to Apple store?

I've been making a game for android using cocos2d-x and I made an apk successfully. now I want to upload it to the AppStore what changes should I make?
1
vote
1answer
239 views

How can i get a value from object in tmx file in Cocos2d x 3.x?

I want to set my sprite in x coordinate based on an object in TMX map file, this is my code: tileMap = cocos2d::TMXTiledMap::create("ground.tmx"); ground = tileMap->layerNamed("ground"); ...
2
votes
1answer
714 views

Why AnchorPoint doesn't affect `CCLayer` Positioning?

I think there is a difference between CCLayer and CCNode behavior when I change their AnchorPoint. I will describe what I mean and please somebody explain it ? Scenario: I start with CCNode CCNode ...
0
votes
1answer
32 views

How to program friction in an air hockey game in Cocos2d-x 3.11?

I'm developing a simple air hockey game, and I have a question about friction of puck and puddles with the game scene. How can I do that? I'm using cocos2d-x default physics engine, and the friction ...
0
votes
1answer
333 views

Cocos2d - Physics bodies randomly loosing Velocity along an axis after impact

This just started occurring and seems to randomly happen during, and between, game sessions. A dynamic moving body collides with a static body and instead of bouncing off looses (almost completely) ...
1
vote
1answer
91 views

Handling animations in a Platformer

I'm developing a 2D platformer game using the Cocos2d-x Engine, i can load correctly the animations according in which action the player is(running, jumping, standing, etc). Now i'm trying to add the ...
0
votes
0answers
12 views

Compiling 'Hello World' Cocos2D-x Project On Mac

I am trying out Cocos2D-x v3.10, but I am getting a compile error because I am missing an sql 3 library. The specific flag that triggers the error is -llibsql3 in the cocos2D_libs.xcode project. I ...
2
votes
2answers
1k views

Drawing a continuous line with onTouchMoved callback

i'm trying to draw a continues spline on every onTouchMoved call, the functionality is supposed to be similar to the line drawing used in the iOS game - flight control. i'm using it in the following ...
0
votes
1answer
30 views

Cocos2d: Tweening primitive data-types

I asked in SO, but no responses so I'm posting here since it's probably more relevant here. EDIT: SO question closed. I'm trying to tween primitive data-types the way Action tweens position to ...
0
votes
0answers
16 views

cocos2d c++ Collision between edge physics bodies

I'm working on a game with cocos2d, need to detect collision between two PhysicsEdgeBody. I've created an EventListener for contact and added it to the layer i'm working on, PhysicsContact and ...
1
vote
1answer
238 views

Cocos2d Sprite 3D position

When I set a position3D for a Sprite in cocos2dx, it render two times the same sprite, i took a screenshot: I set the position3D because i want to use the Z position the give an effect of distance, ...
0
votes
1answer
258 views

Cocos2d-x v3.1 for WinPhone 8 auto change texture after resumed from background

I have some sprites in my game (for Windows Phone 8). These are my steps to reproduce the problem: Open game Play (this is an optional step) Press Windows button to send game to background Press ...
1
vote
2answers
2k views

How to pause and unpause the Particular action of a sprite?

My game has a sprite representing a character. When the character picks up an item, the sprite should stop moving for a period of time. I use CCbezier to make the sprite move, like this: ...
0
votes
2answers
724 views

translate-scroll repeated 2d texture using opengl shader

I managed to implement an infinite 2d texture scrolling using the following shader. btw I'm using cocos2d-x 2.2.1. The vertex shader: attribute vec4 a_position; attribute vec2 a_texCoord; #ifdef ...
1
vote
3answers
942 views

Counting multiple touches using Cocos2dx 3.2

I'm trying to count the number of active touches in screen in order to perform an an action in case that there are two touches: auto jumpListener = EventListenerTouchAllAtOnce::create(); ...
2
votes
1answer
2k views

Need Help with Cocos2d Ver 3.3 AudioEngine

So I have 2 audio files that I want to play at different times: background.wav a sneeze.wav. I believe that I have to convert both wav files into mp3, caf and ogg files. Then I do this: static ...
0
votes
1answer
230 views

How to implement a Trail using Cocos2dx

I'd like to implement a trail (like the white circles in Angry Birds) that chase my sprite. I already used CCMotionStreak, but the trail texture is "stretched" instead. Anyone has an idea how to make ...
0
votes
1answer
693 views

post on Facebook from cocos2d-x on windows phone

Is it possible to share/post on Facebook from cocos2d-x on windows phone. Is there any example/tutorial available.
0
votes
2answers
497 views

Cocos2d-x 3.0 animation frame by frame

As I know animations are actions. Now I need to play animation frame by frame. Say I have an animation from N frames. each frame should be played after t delay. Now I want to play animation frame by ...
0
votes
1answer
169 views

How to convert pixels to meters in Box2d with Cocos2d-x 3.5?

I am using Cocos2d-x 3.5. I created a simple game with edge bodies and one circular body to test box2d. Physics wasn't working well, so i thought i should convert pixels to meters and use that meters ...
0
votes
1answer
88 views

How to connect to a socket.io server from a Cocos2d-x game?

The question can also be asked more specifically as; How do I connect to a socket.io server with C++ from a mobile game? I am aware of Boost (and Socket.io C++ client libraries using Boost) but ...
0
votes
1answer
22 views

cocos2d-x Label Load Image like Sticker-Smile..(by html or …)

hi and sorry for my english... i am using cocos2d-x (c++)... can i load sticker (smile) in my Label(a text mixed by image)? i know that we can load bitmap fonts by: Label::createWithBMFont also i ...
0
votes
0answers
8 views

cocos2d-x Label Set Custom Direction manually

sorry for my english... i am using cocos2d-x for developing an android -ios game... can i set custom right-to-left or left-to-right direction to my Label manually? i mean that i want to set it like ...
3
votes
1answer
2k views

Pixel Perfect Collision Detection in Cocos2dx

I am trying to port the pixel perfect collision detection in Cocos2d-x the original version was made for Cocos2D and can be found here: ...
1
vote
0answers
39 views

Cocos2dx Windows Phone 8.1: Seperate Characters in RTL Label

I use below code to show a text : auto label = Label::createWithSystemFont("سلام و خداحافظ", "BTitrBold", 24); ( RTL text like Persian, Arabic and Hebrew) This code works fine in both **Android** ...
0
votes
0answers
17 views

Cocos2dx : Lua with C++: lua_pcall closing my app

I'll try to explain what is happening with my current project: I want to make some custom scripts myself without using the lua script engine from cocos2dx, so I linked lua51.lib on Linker->Input, and ...
0
votes
0answers
35 views

`setVelocity` allows body to pass through bodies

In my game, I'm using cocos2d-x and I wanted to have an object that changes direction immediately, so I used setVelocity() on the physics body to do that. However, when I do that it can run through ...
0
votes
0answers
26 views

In Cocos-2d-x, is there a way to get a shared OpenGL context for use with background loading

We are using parts of the Cocos-2D-X engine and we have a background loading thread which loads textures in the background. Is there a way to get a ShareGroup so we can safely bind an OpenGL context ...
2
votes
2answers
332 views

Right-To-Left Text Direction in Cocos2dx

I want to use Persian/Arabic text beside English in whether Label or ui::Text. Persian is a Right-to-Left and English is a Left-to-Right language and so I have problem to combine them in one string. ...
0
votes
0answers
41 views

How to do serialization in Cocos2d-x?

I can’t find any examples on the web on how to do serialization in nodes. If there isn’t a mechanism already built-in in the engine for this, is there a common pattern used to implement it in ...
0
votes
1answer
135 views

How can I save and load an adventure game?

I'm using cocos2dx and sqlite to store datum. The table looks like this: x INT, y INT, className TEXT, properties TEXT. I use json to serialize terrains and sprites. But I don't know how to ...
1
vote
2answers
1k views

Playing a sprite sheet animation in Cocos2D-x

I'm trying to create an animation using a sprite sheet in Cocos2D-x. I'm doing the following. The game doesn't crash but the screen is still blank. bool HelloWorld::init() { ...
2
votes
1answer
482 views

Compile cocos2d-x Windows games without Visual Studio

I want to use cocos2d-x to make a Windows game. I used the cocos console: cocos compile -p WIN32 And apparently it needs Visual Studio. Is there an alternative to build the Windows game without ...
1
vote
0answers
27 views

Can I use sdl_net2.0 with cocos2d-x? [closed]

Can I use sdl_net2.0 lib with cocos2d-x? And how it cconects to each other. Or analog lib to use?
0
votes
2answers
3k views

cocos2dx - Custom Fragment Shader and CCRenderTexture

I have a CCRenderTexture that is filled with a sprite when the scene is loaded, as follows, canvas = CCRenderTexture::create(this->getContentSize().width, this->getContentSize().height); ...
0
votes
1answer
1k views

How to set up Cocos2d-x for visual studio?

I want to make a cocos2d-x game. I read you can use any IDE, so I was planning to use Microsoft Visual Studio 2015, since I want to make my game primarily for Windows. I have been searching for ...
0
votes
1answer
71 views

Rotate sprite direction Cocos2d

I want that my sprite go always forward, and you can only control his direction moving right and left (on 360 degrees). I don't know why, but the movement it's senseless. The constants to move and ...
0
votes
1answer
88 views

how to naturally rotate a ball according to its velocity on a surface, a wall

I develop a game on cocos2d-x cpp. There is a ball sprite in my game. I move the ball on a surface(wall) via touch events but it can't naturally rotate according to its velocity. if i use ...
1
vote
1answer
140 views

What is CC_Time in cocos2dx?

I was following this tutorial to understand using custom shaders : http://www.cocos2d-x.org/wiki/User_Tutorial-Realistic_looking_animated_real-time_clouds I understand that CC_Time is Cocos2d-x ...
2
votes
2answers
87 views

How to handle sounds muting in settings?

I have a easy and specific question. Let's say that in my game I use singleton for playing/pausing/changing volume of specific sounds (SimpleAudioEngine in cocos2d-x). What is the best way to ...
1
vote
1answer
160 views

How to make TMXTiledMap responsive?

I've been struggling with Cocos2d-x (C++) and finally I got to the point I feel more or less comfortable with that. My game is a 2D car-based one, with a straight infinite map where I've finally been ...