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
0answers
20 views

change animations when touch sprites

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
25 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; ...
1
vote
1answer
63 views

having problem with preloading plist file in Cocos2d-x

I am using Cocos2d-x engine with 3.2 version. In my splash screen i am prefeching plist by below line SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ui.plist"); Now inside game when ...
0
votes
1answer
40 views

cocos2dx: Your RunningScene != Scene You just Replace

I have this code for cocos2d-x 3.x: void MainMenu::StartGame(cocos2d::Ref* pSender) { auto director = Director::getInstance(); auto newScene = Scene::create(); ...
0
votes
2answers
215 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 ...
0
votes
1answer
147 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 ...
3
votes
1answer
221 views

How do I handle rope physics with fixed ends and a sliding weight?

I've been interested in rope physics recently—I've successfully implemented a simple Verlet rope with moveable ends. Now I am trying something a little different: I want to start by recreating the ...
0
votes
1answer
77 views

how can i remove CCSprite on click which are came from right to left direction…? [on hold]

i am using cocos2dx 3.0(c++) and have many sprites generate from on sprite named "objDown". each generated sprite has a setTag() assign ...no w how can i remove this sprites on touch ....help will be ...
0
votes
1answer
50 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
218 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
278 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
101 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 ...
0
votes
1answer
301 views

Multi Resolution graphic for ios 4 and ios 5

i have used cocos2d-x to code game for ios 4, ios 4s, ios 5 with screen size (3.5 inch and 4 inch) First, my resource are desgined for ios 4 and ios 4s with screen size : 3.5 inch. so if i want to ...
0
votes
1answer
134 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
1answer
228 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
2k 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
2answers
305 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
0answers
28 views

Grayscale and 2D lighting using cocos-2dx

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 ...
3
votes
2answers
218 views

Implementing one-way platforms in Chipmunk

I am making game in cocos2d-x, but it's the first time I am using a physics engine i.e. Chipmunk. (It's built-in to cocos2d-x.) I want to make a one-way platform: When my character jumps into a ...
0
votes
2answers
461 views

CCMoveBy values on update()

Hope you can help me. 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 ...
1
vote
1answer
216 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 ...
1
vote
1answer
169 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 ...
0
votes
1answer
88 views

Cocos2d-x how to draw in specific free form area

Here https://github.com/mikeccy/cocos2dx-finger-paint/blob/master/Classes/HelloWorldScene.h and https://github.com/mikeccy/cocos2dx-finger-paint/blob/master/Classes/HelloWorldScene.cpp you can see how ...
0
votes
1answer
112 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
61 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 = ...
-2
votes
2answers
440 views

Tower Defense Search Enemies Efficiently

I had a problem with the build of a TD. I got a slow - non efficient search for towers find targets to shoot. PD: enemies[] got all the active & non-active enemies (death and alive) ->Im using ...
0
votes
2answers
85 views

Filling up the empty blocks when the player touches the safe zone again! using cocos2d

Hi guys i am stuck with filling up the data of all the blocks which are empty like the ones in the image. As you can see there i have a pacman like object where i will be moving around. But when ...
0
votes
0answers
17 views

applyImpulse on CCSprite not making realistic moves

I am developing a jump game, in that when tapped on screen, I need to make the player jump up. So, I used following code. [_player.physicsBody applyImpulse: ccp(0, player.physicsBody.mass * 155)]; ...
2
votes
0answers
157 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
0answers
47 views

Touch-detection in cocos2d-x (Lua): Catering for bounding boxes and scale factor

I am trying to write an app in Cocos2d-x with Lua. I have a sprite that I have added directly to a scene, and now I want to detect touches on the sprite. Right now, my touch begin function looks as ...
0
votes
1answer
41 views

using rperp or perp to find perpendicular of a vector

i have code local coordinate Vec2 velo = Vec2(100,0); Vec2 Heading = velo.getNormalized(); Vec2 side = Heading.perp(); Vec2 trans = Vec2(12,12); then i can generate toWorldCoordinate for trans ...
0
votes
0answers
53 views

Cocos2d-x 3.0 JS: Facebook Dialog: Internal Server Error 500

I am using the following function to Invoke Facebook sharing: facebookShare: function() { cc.log('share to facebook 0.1'); var self = this; var fb = plugin.FacebookAgent.getInstance(); ...
0
votes
0answers
75 views

Use other IDE then Eclipse on OSX for game dev with Cocos2dx for Android [on hold]

I've started with cocos2dx 3 days ago and already having a massive pain in my "back" with this support of C++ that eclipse provide me. It support it a little bit more then notepad++, and after years ...
1
vote
2answers
449 views

how to re-use a sprite in cocos2d-x

some times it takes time to create the sprite structures in the scene, I might need to setup structures inside this sprite to meet requirement, thus I would hope to reuse such structures with the game ...
1
vote
0answers
64 views

Render isometric TMXTilemap with antialiasing method

I'm currently working on a cocos2d-x project that uses isometric tile maps.all the tiles are as small as 64*64 px.So I have to scale the map up a little bit.TMXTilemap is handy but its render method ...
0
votes
3answers
158 views

Is this possible in cocos2dx 3.0? [on hold]

I have a number of five images (sprite1.png, sprite2.png, sprite3.png, sprite4.png, sprite5.png), these all I want to add as a sprite... int rndSprtNum = (arc4random() % 5) + 1; for(int i = 0; i < ...
0
votes
0answers
63 views

Change of scene not working in Android

Hi i am trying to load a new scene in cocos2d-x-js version 3.0 and my code works fine in the windows simulator but on building to android it doesn't work. This is the code var scene = new ...
-1
votes
1answer
468 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
0answers
14 views

How can I animate a sprite in cocos2d-x 2.2.1 c++? [duplicate]

Is there a way to do an animation without a .plist file? I'm having a hard time doing swap animation with sprites. For example, doing an animation while the user is not doing touches and the other ...
9
votes
3answers
13k views

How to play animations in Cocos2d-x?

I'm new to Cocos2d-x and looking for a good way/tutorial on how to play animations in Cocos2d-x.
2
votes
2answers
194 views

Water silhouette shader using GLSL

I have this problem to solve using Cocos2d-x 3.x: In my game there is water represented by rectangle texture, modified by the code on the go. I also have a character moving around, rotating etc. I ...
1
vote
1answer
166 views

cocos2d-x “immediate mode”?

I have some c++ game code that draws the game state on each game-loop cycle in "immediate mode". By that I mean that the game code does not add the sprites to be drawn to any sort of "scene graph" or ...
2
votes
1answer
457 views

Not able to change the background of the scene in cocos2dx android

I have started Game Development using Cocos2d-x. And started with HelloWorld sample game. I am able to run this sample game. But when I try to change the Background Color, I am getting error in ...
1
vote
0answers
131 views

How to change texture from pvr.ccz in Cocos2d?

I'm using .pvr.ccz file that texturePacker application created for me , I created a Sprite that it's image choosed from this file(.pvr.ccz) like below: CCSprite *mySprite = ...
0
votes
0answers
445 views

CocoStudio + cocos2dx 3.2 correct way to import animation?

After many frustrating hours I came to the conclusion that there is no valid way to implement a cocostudio animation, as CCArmature is deprecated and didnt work for me anyway. CocoStudio.h and ...
0
votes
0answers
106 views

Is there any advantage in using sprite sheets in Cocos2d-X menus?

I am developing a game using Cocos2d-X 2.3 and Marmalade SDK 7.3.1 and I was wondering if there is difference between loading the icon images that will be used in my menu buttons from a sprite sheet ...
0
votes
0answers
29 views

Add spritenode to the side of other spritenode

i have create a spritenode space. i want to add one sprite node to the left and one sprite node to the right of the space node. space= Sprite::create("space.png"); ...
0
votes
0answers
127 views

How to create a rectangle sprite node in cocos2d-x

I am new to cocos2d-x. I want to create a rectangle spritenode with specific size in cocos2d-x. As in spritekit we use "bodyWithRectangleOfSize", what is its equivalent in cocos2d-x. I am using ...
0
votes
0answers
172 views

cocos2d-x .. How to detect which sprites are underneath a touch event

I was wondering what the best solution is in the following scenario: Lots of sprites floating around on screen. A user can touch one sprite and drag to another sprite. Throughout this entire time, I ...
1
vote
1answer
502 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 ...