cocos2d for iPhone is a free open-source framework for building 2D games, demos, and other graphical/interactive applications for iOS devices.

learn more… | top users | synonyms

1
vote
3answers
363 views

Getting different x and y coordinates for touched location on a zoomed view

I'm using Cocos2d for developing a game. I need to be able to pan and zoom when necessary, so for this reason I've added CCLayerPanZoom extension to my project. Recently I've noticed a problem with ...
0
votes
2answers
102 views

How to define axis of Sprites in a CCAnimation?

I'm struggling to find how to define a kind of axis in my frames, when my sprite punches it moves back. I want to define the head as a pivot for the other sprites with different sizes. How can I ...
3
votes
1answer
1k 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: ...
0
votes
1answer
295 views

iOS with cocos2d to MVC or not to MVC?

I am working with cocos2d. All my objects are declared on the CCLayer that I'm using, I have the logic of the game there and all the CCSprites. Should I put the CCSprite for the player and all it's ...
0
votes
1answer
161 views

How do you align the edges of sprites?

If you have SpriteA and SpriteB. SpriteB is a child of SpriteA. Does anyone have a mechanism to come up with the left, right, top, side of a boundingbox() of SpriteA? What I'd like to do is align ...
0
votes
0answers
155 views

How do I find the rotation point given a touch anchor, new position and new rotation?

I've got an Cocos2d layer which anchorPoint, position and rotation (according to http://www.qcmat.com/understanding-anchorpoint-in-cocos2d/) vary when the pinch zoom gestures. Everything works fine. ...
0
votes
1answer
210 views

how to improve sprite animations to reduce FPS

My game has different, and detailed animations throughout the game. For example, the main character has an idle stance, so its not just painted still, giving him some life. Death animation, hurt ...
0
votes
1answer
97 views

Cocos2d When The Loading Screen Scene is loading music

When the loading screen loads objects like music cutscenes, the idea is to preload the objects, so... what should happen next? Do I transfer the objects to the next scene? or these special objects, ...
0
votes
1answer
594 views

Cocos2d how to correctly preload a spritesheet before the scene start?

I'm working on a game with Objective-C and Cocos2d, the game has a huge number of images, and obviously as I add images on the spritesheet (well yes I'm using spritesheets) the loading time get ...
0
votes
1answer
205 views

How to use UILongPressGestureRecognizer with sprite drag & wait?

May be it's asked before also but I couldn't find any good answer. Please tell me how this can be implemented with UILongPressGestureRecognizer? A user drags a sprite from X location to Y location. ...
1
vote
0answers
131 views

UITapGestureRecognizer fast tapping not working [closed]

I have initialized UITapGesture as follows: tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; tapGestureRecognizer.numberOfTapsRequired = ...
2
votes
1answer
83 views

Display CCSprites with a delay

I am a beginner in cocos2d and I wanted to display coin CCSprites as soon as it moves off the screen with a 5 second delay. So this is what I wrote in my main gameplay layer to add 7 coins in a row: ...
3
votes
1answer
266 views

How can I apply a “genie animation” to a CCSprite?

I am new to Cocos2D and following this tutorial. I want to animate a CCSprite with the genie effect that OS X uses for hiding windows to the dock and showing them again. Here's an example from an ...
9
votes
2answers
647 views

How do I simulate a swinging pendulum?

I want to simulate a rope with a weight attached, swinging back and forth like a pendulum. Any actual physics is overkill; it's just endlessly repeating the same motion. JQuery has a the "swing" ease ...
5
votes
1answer
266 views

How can I implement a “Nyan Cat” rainbow?

I'm currently making a game similar to this Nyan Cat flash game, although I'm using cocos2d. I'm having a hard time trying to make the rainbow effect: Currently, every update call I add a piece of ...
3
votes
3answers
377 views

What is actually loaded during a game's loading screen?

I am at the stage of my game where I have to develop the loading screen. It's actually already there, but I don't know exactly what it should be loading while it's presented. Why would I have a ...
1
vote
1answer
861 views

2D Destructible Terrain with Box2D / Cocos2D -> Image Tracing

Bear with me as this will be a rather lengthy post. For the last month I have been working on an open source Cocos2D, Box2D Destructible Terrain Engine. I have some questions regarding its ...
4
votes
1answer
117 views

Is it better to preserve scenes in memory or recreate them every time I need them?

I am using Cocos Builder to create scenes using sceneWithNodeGraphFromFile:owner:. Now I have doubts about whether it's better, on iOS, to save some memory or CPU cycles. In other words I have two ...
-1
votes
2answers
454 views

Drawing line from sprite with a touch

I am working with cocos2d for the iPhone and I have a question about how to implement the following. I have a circle shaped sprite on my layer. When I touch the sprite and move my finger a line must ...
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 ...
1
vote
1answer
132 views

CCParticleSystemQuad works as intended every second time

I'm using CCParticleSystemQuad for particles, loading it from plist: flourEmitter = [CCParticleSystemQuad particleWithFile:@"FlourParticles.plist"]; But it works not every time. Every second or ...
1
vote
1answer
197 views

Cocos-2D asteroids style movement (iOS)

So I have a CCSprite subclass, well call this Spaceship. Spaceship needs to move on a loop, until I say othersise by calling a method. The method should look something like - ...
1
vote
1answer
102 views

Ring and Pole - Box2d

How I can make a b2Body in box2d so that it could form a ring which does not collide from the center just like a ring. like when we flick the object and there's another body (like pole), the pole can ...
1
vote
0answers
129 views

cocos2d openGL swapbuffers leak [closed]

I am using cocos2d and experiencing a very strange issue. My memory allocation keeps increasing on every drawScene call. I've tracked the problem to the swapBuffers call but I have no idea why this ...
0
votes
1answer
178 views

Simple Bounding Box Multiple Collision problem

I'm making my first game, and in it I use a moving ball to hit static blocks (kinda like breakout). Basically, I loop through all of the static blocks on the screen each frame, update the position ...
0
votes
1answer
931 views

cocos2d-x - object creation and management in game design

How do others keep track of everything going on in their games? I am working on a new game and I am quickly realizing everything that I need to keep track of. Example: Maybe a layerManager that ...
2
votes
4answers
375 views

Timing - use individual timer for every task or global timer?

I'm writing a game, where a player controls a spaceship. It regenerates energy over time. So I need to make a little timer that adds certain amount of energy to the pool per second. My enemies also ...
0
votes
1answer
48 views

Calling CCRepeaForever on CCLabelTTF Makes Label Not Show Up

I have a CCLabelTTF in the top right hand corner of the view. -(void)scrollScoreLabelAndMonkey{ scoreLabel = [CCLabelTTF labelWithString:@"0000" fontName:@"Marker Felt" fontSize:30 ]; ...
0
votes
1answer
151 views

Set texture of a LHSprite that is loaded from LevelHelper

How do i set the image/texture of an LHSprite that is loaded into xCode using levelHelper & spriteHelper? I am using sprite sheets. So i tried to load the image the old fashioned way using ...
0
votes
1answer
150 views

Projectile immediately intersecting with target

I have a fairly simple and somewhat cookie cutter method for testCollisions: (FYI: BasicProjectile is a CCNode with a CCSprite member). for (BasicProjectile * basicProjectile in ...
1
vote
1answer
243 views

opengles display human face in iphone and animate it?

I need to make a human 2D face to 3D face. I used this link to load an ".obj" file and map the textures. This example is only for cube and pyramid. I loaded a human face ".obj" file. This loads the ...
0
votes
0answers
117 views

cocos2d - exclude GUI layer transformation

I have a game layer that should be pannable and pinchable and a GUI layer as an overlay that's excluded from the transformations. I added the pinch and pan gesture recognizer to the view and set the ...
0
votes
1answer
567 views

Using depth buffer on a sprite

I am following this guide: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps Trying to create a tiled map that also supports multiple layers. The guide says that a way is to use ...
1
vote
0answers
309 views

iOS cocos2d - sprite gets stuck in collision detection

I'm developing a top down game in cocos2d and I have collision code that checks collisions between enemies and the player so that they don't go through each other. The code seems to work but the ...
4
votes
1answer
664 views

Collision Filtering in Box2D

I have four bodies in my Box2D World. Each are polygon shape, with some physics parameters. Now when the game start, I need one of the bodies from the World (BodyA) to not be allowed to collide with ...
1
vote
0answers
202 views

Detect Sprites, they are in Shape or Not which random draw in Cocos2d

I have searched a lot on web and found some of help ful links as exact my question. Link 1 Link 2 But still i am not success to achieve this, i have done some of code lines, as like draw line by ...
2
votes
0answers
408 views

Can I use a shader with 2 different textures in Cocos2D (x)?

We are evaluating a variety of different graphic engines for use in our game and we want to be able to use 2 different textures for many of our sprite maps. One sprite map would be the standard RGBA ...
0
votes
1answer
178 views

DPad style movement for AI without using A*

What is the easiest way to implement DPad style movement (No diagonal) for AI without using and A* algorithm? I thought about having the enemy catch up to the player in the Y axis first then the X ...
1
vote
1answer
116 views

TiledMaps and real objects

I'm creating a simple game for the iPhone using Cocos2d. I'm having a hard time understanding how add real objects to a tiled map. I know that you can add an object-layer to the tiled map and set the ...
1
vote
1answer
1k views

3d transformation of game world keeping gameplay 2d - COCOS2D 2.0

Using: COCOS2D + iOS. I want to rotate the game world, may be loading another .tmx file for another dimensions when user want to switch dimension. the effect what I am looking for is something like ...
0
votes
2answers
87 views

CCSprite as an iVar

So I built my first game app, and it was a lot of fun. I'm really trying to expand on some of the ideas, but I'm running in to some serious variable scope issue. What I want to do is encapsulate a ...
0
votes
1answer
482 views

Remove HUD from Child Scene

For my game, I create game scene for which I set HUD to it. First my game scene use BoundCamera, so I use hud to set score text, dollar text and setting button. Now on game scene when I touch on ...
1
vote
2answers
343 views

Cocos2d savegame cctmxtiledmap

my game features several tilemaps that are initially loaded from a tmx file and modified during gameplay. How can I save the changed tilemaps in a save game? Will NSCoding do the trick here or is the ...
0
votes
1answer
492 views

Cocos2d patterns for simple texture management

I'd like to simplify the way I preload image resources in my Cocos2d based iOS apps. I've created a small object the just wraps a few of CCTextureCache's methods. It looks like this: @interface ...
2
votes
1answer
319 views

Handle Multiple Scene

For my game, now I adopt the strategy to create multiple scene. For this I have to ask two question please provide your view for my and other members for improvement. I have created single ...
0
votes
2answers
165 views

Can CCAnimations be paused?

I am new to cocos2d. I am using CCAnimation. It's working fine, except I want to pause the animation occasionally. How do I do this? Here's what I'm doing so far: [mySprite ...
2
votes
1answer
364 views

Blending transition in cocos2d

In my cocos2d-iphone game, I have 2 backgrounds (CCnodes), each containing a quite complex hierarchy of sprites. I would like to make a smooth transition between them: initially, only the first ...
4
votes
2answers
1k views

Presenting game center leaderboard

I have the following code: -(void)showLeaderboard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { ...
0
votes
1answer
1k views

Integrating game center into cocos2d

I have a Cocos 2d game in which I want to have achievements and a leader-board. What are the steps I would need to take? Thanks P.S All of the tutorials I have found are outdated. So please write ...
3
votes
0answers
309 views

How to achieve 'forward' movement (into the screen) using Cocos2D?

I'm interested in creating a 2.5D first-person shooter (like Doom) and I currently don't understand how to implement the player moving forward. The player will also be able to browse around the world ...