3

Add a new Layer and put there a Menu object with the buttons you need. Make the layer visible when the game is over.


3

I think you're getting your pixel coordinates and tilemap coordinates confused. Tile coordinates count tiles. Pixel coordinates count pixels. To convert from a pixel coordinate to a tile coordinate, divide the click_x by the tile width and the click_y by the and tile height, to get the tile coordinates x and y. (Discard the remainders to get an integer.) ...


3

The difficulty of an endless runner is dependent on a few things, first of all the size of the obstacles and different types of obstacles, typically it's best to just hardcode when different obstacles can appear and use a formula for sizes (especially when you can only use a given dodge ability for a certain amount of time). A good formula for the size of ...


3

One option is to overlay a texture that has a blend mode of Multiply set to it over your tiles. The overlay texture would be almost black (dark shades of grey) all around, except for the area you want to be fully visible, which would be white. Multiply blend mode will darken all the black areas and the white areas would remain unaffected. Here is a sample ...


2

Do as ryrich said, however the actual code on Objective-C would be something like this: (Assuming your CCNode class is called "Seal") int sealCounter = 0; for (id *node in self.children) { if ([node isKindOfClass:[Seal class]]) { sealCounter++; } }


2

Let's speak radians. Your angle is clamped to a real range and from what I can see from your video I would say between −π/2 and 3π/2. Now you can also view angles in different ways, for example as points on a circle. This is clearly the intuitive way to see your problem : in your case the tip of your ship is the considered “angle point” on the circle. ...


2

Regarding the info found here, currently there is no official way to achieve this but they are working on it. Meanwhile you can download the "standalone template" found in the same link.


1

Just slow it down or speed it up with a force proportional to the error. If your intentions were to hit a certain position for your object, you would actually need something more advanced like a Proportional Integral Differential Controller. But if you merely aim for a certain velocity, not a certain position, then its quite easy by setting a force each ...


1

You can check the velocity in your update function and set it to some max value if the calculated value will be greater than that max. This way you still use force and allow it to stop when it collides with another object, but it will never be able to go faster than the maximum velocity you set.


1

The trick is to use the CCScrollViewDelegate methods to detect scroll events. Add a CCLabelTTF and call it _pageLabel. In Xcode, make the scene containing your scroll view adhere to the CCScrollViewDelegate : @interface myScene : CCNode <CCScrollViewDelegate> Then, in didLoadFromCCB, set the scroll view delegate to self : _scrollView.delegate = ...


1

If you have sleeping allowed (and the b2_timeToSleep is sufficiently short for your needs) you can use the b2Body::isAwake function to test if a rock is settled. Pseudo-code: For body in bodies: If(body is rock and not body->isAwake()) Then //Apply impulse End If End loop


1

Yes, cocos2d-x has a built in way to do this. If you want to pause everything the character is doing you can simply use: _character->pause(); _character->resume(); _scheduler->pauseTarget(_character); _scheduler->resumeTarget(_character); NOTE: this also pauses any actions being performed on the character. If you want to continue ...


1

You could try this: [yourSprite pauseSchedulerAndActions] and to resume [yourSprite resumeSchedulerAndActions] Source: SO thread If that shouldn't work, another option might be: //pause [sprite.actionManager pauseTarget:sprite]; //resume [sprite.actionManager resumeTarget:sprite];


1

Well, one way is to load the textures and keep a reference to them ourself. You could reimplement your code to something like: @interface TextureHelper : NSObject - (void) preloadTextures; - (CCTexture2D *) textureForImageNamed:(NSString *) imageName; @end @implementation TextureHelper { NSArray * loadedTextures; } - (CCTexture *) textureForImageNamed:...


1

That error occurs on this line: CCTexture *texture = [CCTexture textureWithFile:image]; And this is the right way to do this: CCTexture *texture = [[CCTexture alloc] initWithCGImage:image.CGImage contentScale:image.scale];


1

This work! in cocos2d 3.x NSMutableArray *frames = [NSMutableArray array]; int frameCount = 0; for (int i = 1; i <= 5; i++) { CCSpriteFrame *frame = [CCSpriteFrame frameWithImageNamed:[NSString stringWithFormat:@"dice0%d.png",i]]; [frames addObject:frame]; } CCSprite *sprite = [CCSprite spriteWithSpriteFrame:frames....


1

I am not seeing where you are positioning the particle system, only that you are adding it to "self". I assume you want the particle system to be more or less at the same position as the star sprite. Assuming "self" is a layer, you need to position the particle system using the position of the star sprite, and offset the position where needed. ...


1

Since you have already solved the first problem, I will only address the second problem The code you have does not really show where you generate the model, view & projection matrices, so it is difficult to exactly pin-point the problem position for you You should maintain separate View & Projection matrices. If you use a library such as glm, which ...


1

It appears that setting self.hitAreaExpansion might be the answer, however it only needs to be set to the difference between the edge of the view field and the edge of the map, for the largest difference on either axis. In this case the map is square, 1600 x 1600, and the view port is 320 x 480, so the greatest distance is 1600 - 320 = 1280. self....


1

If you are using DFS starting from the top, all unvisited nodes should drop. The top should be an invisible node connected to all top bubbles (in the top row). One thing worth noting, is that unlike the current DFS which is checking for color equality, the functionality you should use for deciding which bubbles to drop because they are hanging in the air ...


1

It looks like it is probably based on curves - like maybe piecewise Bezier curves, or maybe B-splines. Internally in the code they could also be using hermite splines, catmul-rom splines or some other variant but without seeing the code its nearly impossible to tell what specific curve is being used since many of the above are visually equivalent, but are ...


1

By "endless levels" do you mean that there is no limit to the number of waves i.e. the waves keep coming until game-over? If so then you need to develop an algorithm that takes the wave number as an input and returns an set of enemies suitable for that wave. The most trivial of these would be to take the wave number and return a number of enemies or as ...


1

Basic sprite animation is really simple: int frame_to_play = (game_tick * target_fps / tick_rate) % number_of_frames; The result will tell you which frame (the frame_to_play-th) to show. game_tick would be some kind of frame counter that just counts up (has to tick at least as fast as your animation is meant to be played). target_fps is the framerate at ...


1

it seems i was having memory Issue : i Change my code like this : In updateCacheImage method : You need to put Your imageContext in AutoReleaspool to free up your memory. @autoreleasepool { // init a context UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); //End Context UIGraphicsEndImageContext(); } i also have make my objects ...


1

Have you looked into CCPhysicsSprite? Otherwise you can use the b2body.userData pointer to store sprite information after you've created your physics body.


1

It looks like your image has an anti aliasing at it's border. You can either fix this in photoshop or you could use a program like texturepacker that will extend your picture a pixel and remove this border.


1

Don't know if this will help but here is the code for a game where we have moving clouds in the background. Is very old but will get you an idea. -(id) init{ if( (self=[super init] )) { first = [CCSprite spriteWithFile:@"clouds_1.png"]; firstWidth = first.contentSize.width; height = first.contentSize.height; second = [...


1

Your solution, thus-far, implies you are already calculating depth to determine the scale factor needed to simulate perspective. To make objects move "behind" the camera, test that same depth when you draw them and do not draw objects whose depth indicates they should be behind the camera. if (object.sceneDepth >= 0) object.Draw(); Re: (like Doom) ...


1

Found the following answer over here. Grab the following image: http://i.stack.imgur.com/O5DRf.png. It is 2x30. I want to make a bar that is 15 pixels high. Normally, the dimensions would be 1x15, but since I assume you're working with retina display, we have to double such dimensions to 2x30. Create a CCSprite with it, and set the anchor point to ccp(0.0,...


Only top voted, non community-wiki answers of a minimum length are eligible