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

0
votes
0answers
19 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 ...
1
vote
1answer
218 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
0answers
21 views

cocos2dx - Swipe and cut the sprite

I am trying to implement swipe and cut a sprite using cocos2dx and inbuilt chipmunk. The image below explains what I want to do For the solution I have done following things Enabled physics in ...
0
votes
0answers
26 views

Very slow motion smooth rendering - cocos2d-x

I have a a white circle that I move on a black background very slowly. When I look very carefully, I see that the while moving the edge of the circle is jittering. In my opinion it is because the next ...
0
votes
0answers
13 views

Setting Up the PTM_Ratio for Different Devices

I want to set the the physics for my Game and I have used Box2d for the Physics Simulation. And to do that I have set the PTM_Ratio to 32.0f.But When I run my Game on Different Android or iOS Devices ...
0
votes
1answer
146 views

Error running an Action in Cocos2d-x

In my game I have a "rocket" type and I want to run a sequence of actions on it. At first it must run an explosion animation and then remove itself from the game. For this I used the following code, ...
0
votes
1answer
69 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) ...
0
votes
0answers
11 views

cocos2dx - Bypass body contact

I am using cocos2dx and setup two Sprites with same Physics Body definitions see below PhysicsBody *physicsBody=PhysicsBody::createBox(size,PhysicsMaterial(1.0f,0.0,0.5f),Vec2(0, size.height*0.5)); ...
0
votes
0answers
20 views

Shader to mask image with polygon

I'm new to graphics programming and GLSL in particular. I'm working on a 2D game and the setup is as follows: There is an image on the screen (a sprite in the game engine [Cocos2d-x if it matters]) ...
0
votes
2answers
301 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
2answers
586 views

CCMoveBy values on update()

This is my problem: I have a scheduled update, here I track the movements of my objects (sprites), I move them with CCMoveBy, and I need to constantly update the zOrder. For setting the zOrder I've ...
0
votes
1answer
188 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 ...
0
votes
0answers
30 views

How to use a sprite class in cocos2d-x? [on hold]

I am writing a game and would like to add child from a different class (Actor.cpp). I try two method to implement the sprite, but neither can show the sprite on the simulator. Do I implement it wrong? ...
0
votes
1answer
40 views

Cocos2dx - Touch not recognized on Android

I'm having trouble with a touch listener not picking up touch events on android, but doing fine in windows (mouse input). I've got a Node listening for touches (not a Layer), but from what I've been ...
0
votes
2answers
199 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 ...
1
vote
1answer
59 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
1answer
126 views

Cocos2dx - Trail

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
2answers
249 views

Cocos2dx - Physics - Abort() When Changing Dynamic PhysicBody to Static?

I just learned cocos2dx v3.3 integrated chipmunk physics engine. Here ,as you see, I create a simple circle with physic as: auto sprite = Sprite::create("circle.png"); auto body = ...
0
votes
2answers
286 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
378 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
440 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
1answer
818 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
1answer
22 views

how to build release version mac cocos2dx?

do you know how to build mac build release version? in this case i use cocos2dx framework. in vs2013 we easyly choose the build version but in xcode i dont know. the indication release build is all ...
1
vote
1answer
265 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() { ...
0
votes
2answers
662 views

How can i create a message box with callback on ok?

I need to create a message box with ok button and when user touch ok , it will have to execute a callback.I am new to this and couldn't find any articles in the doc.
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); ...
1
vote
1answer
132 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
369 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 ...
0
votes
2answers
317 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(); ...
4
votes
1answer
5k views

why is Lua so important ( frequently used ) in game development [duplicate]

I have written some small games for fun myself, but never used Lua myself. I have seen people discussing Lua's use in games everywhere. The question is: What benefit can I get from using Lua in game ...
-1
votes
1answer
134 views

How to optimize my lighting shader?

I want to create a lighting effect on a gray-scaled world using cocos2d-x. What I've done is creating a layer which runs a shader program that receives light positions and radiuses as input and ...
1
vote
0answers
65 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(); ...
0
votes
0answers
42 views

Cocos2dx How to show different parts of a scene in a split screen

I come from an SFML background and you could show different parts of a scene in split screens by manipulating sf::View. Is there any way to do it with Cocos2dx? I plan to make a split screen game but ...
1
vote
0answers
31 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"); ...
0
votes
0answers
37 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 ...
0
votes
0answers
26 views

Mobile game: Optimization only working on some devices / Render big texture causes stuttering after level load

I'm currently optimizing the rendering of the background of my mobile game. The background consists basically of many colored dots. Since the background is static I'm able ro render the whole ...
0
votes
1answer
48 views

How to serve user generated levels? [closed]

What is the easiest way to store online and serve user-generated levels? What client-server architecture should I use? Will I need backend code, or just a database? What database would be the easiest ...
1
vote
0answers
146 views

How do I use CC_CALLBACK for external classes in Cocos2dx v3.2?

I've been having problems with using 'CC_CALLBACK_#' (i.e. CC_CALLBACK_0, CC_CALLBACK_1). It works alright if I am using it to call a function from the class (Using 'GameScene' class for this example) ...
0
votes
1answer
386 views

Randomize and display sprites in a 4x6 grid - Cocos2d-x

I am creating a card matching game. I have a vector that stores 16 unique cards. I am trying to randomize the order and select only the first 12 cards, then setup in a 4x6 grid for a total of 24 ...
4
votes
2answers
2k views

How to achieve smooth movement with a fixed timestep

Previously in the update method of my game I was using a variable time step which provided very smooth movement of a player sprite except when the frame rate would drop, even slightly. At that point I ...
4
votes
1answer
1k views

Isometric Tile maps in Cocos2d-x [closed]

Is there an specific isometric tile map handler in cocos2d-x? I can't find any.
0
votes
0answers
80 views

Cocos2d pause game freezes the screen

I am trying to create pause screen for my game. The game is developed upon continuous scrolling background (top to bottom) with obstacles which are moving independently (left to right). Below is the ...
0
votes
2answers
334 views

Multi Resolution graphic for ios 4 and ios 5 [duplicate]

I have used cocos2d-x to develop a game for iPhone 4, iPhone 4s, iPhone 5 with different screen sizes (3.5 inch and 4 inch) First, my resource are designed for iPhone 4 and iPhone 4s with 3.5 inch ...
2
votes
1answer
564 views

Cocos2d-x supporting multi-resolution using density independent pixels

Is there a way to use Density Independent pixels(dp) in cocos2d-x? I am developing an Android game using Cocos2d-x 3.0. The Android reference ...
0
votes
0answers
96 views

Playing Multiple Sound effects isssue in cocos2d-x

Please help if someone faced this issue. I have a sound effect 3sec long which need to be played repeatedly for some time of 10 to 15 secs. Implemented like below: ...
1
vote
1answer
948 views

How to prevent showing outside of Game Map ( Cocos2D-x ) ( Scrolling game )

I'm trying to make a tower defense game and it can zoom in/out and scrolling over my world map. How to scroll over the game and how to restrict it not to show outside of my map(black area). At below ...
1
vote
1answer
290 views

Box2d - Attaching a fired arrow to a moving enemy

I am firing an arrow from the player to moving enemies. When the arrow hits the enemy, I want it to attach exactly where it hit and cause the enemy (a square) to tumble to the ground. Excluding the ...
0
votes
0answers
478 views

Implement Camera (former: CCCamera) v2 in cocos2d-x v3.3

we want to port camera code from cocos2d-x version 2 to version 3.3 with the goal to imitate the behaviour of a CCCamera in cocos2d-x version 2 exactly. You can assume that values for "eye" and "up" ...
2
votes
1answer
84 views

change animations when touch sprites [closed]

In the following function I want to change the animation when I touch on the button. But the game crash and exit. What's wrong with this code ? bool GameScene::onTouchBegan(cocos2d::Touch *touch ...
1
vote
1answer
80 views

How can I obtain information about the GPU in Cocos2d-x?

I'm trying to obtain information about the GPU that is running the game in order to use the correct texture compression for that GPU: std::string GPUInfo::getTC() { std::string TC; ...