Hot answers tagged

6

Do it via events. Spell begin is an event. Start playing the sound for that event. Enemy getting hit by spell is also an event. If the enemy is further away and you Throw a dart, for example, you only play the second sound (dart hitting) once the dart reaches the target (if you consider Throw as a spell). If you need to tie it to a frame (so for example,...


6

You don't speed up the engine, you speed up your units and their actions. For example, when you update an enemy, you usually do something like enemyDirection * enemySpeed * timePassed to get their new position. Now, if you want to double or halve the speed of gameplay, you just add this in as a factor: enemyDirection * enemySpeed * timePassed * ...


5

You can only call [self presentModalViewController...] from a UIViewController (or one of its subclasses). In Cocos2d 2.0, the CCDirector is a subclass of UIViewController, so you can do something like: [[CCDirector sharedDirector] presentModalViewController...] (In previous versions of Cocos2d, I think you need to latch back to the RootViewController, ...


4

My second question is that my actual game scene uses bound camera and I perform scrolling on that camera but my other scene uses the normal camera. So in this situation what to do? how to use multiple camera for single engine? or how to reset available current camera? Our 3d game engine allows us to create as many render targets we wish. A render target is ...


4

I will talk how I render those things in my game. My background (parallax) is divided in four segments. The game starts with the three segments on the screen, but as the player moves forward, the forth start showing up and the first starts disappearing (in the left side). Once it completes disappear, I move that segment to the front, and keep doing it. ...


4

Since cocos2d is OpenGL based (sprites are just textured quads), you can create one large quad and modify the UV coordinates accordingly. You don't have to mess with the UV coordinates yourself, cocos2d has some helper methods for that. In order to have an image repeat over the whole screen, you can do something like this: // get the screen size CGSize ...


4

Use Approach #2 (render to a small offscreen texture, then display that texture onscreen scaled up using nearest-neighbor texture sampling), because: The asset workflow is simpler. You can edit individual pixels, without having to quadruplicate them, or manually scale everything up. The assets will probably take up less space on disk. This is particularly ...


4

Frames Per Second (FPS) should be just that. The number of frames drawn every second. What FPS is not is something that you should be basing your gameplay timings around. You are running into issues when spawning enemies according to elapsed time because the rest of your game is not based around time, I bet. In your current setup I imagine you are updating ...


4

I think your basic idea is sound. I'll summarize what your current code is doing. To get the average normal within an area around a point, you're gathering all the pixels in a rectangle centered on that point. For all the pixels in the rectangle that are solid ground, you're averaging the vector from the pixel to the query point. Effectively you're ...


4

There are a number of things to ask, but if you understand the basics you should be able to not just determine the speed your sprite is moving but dictate it. Unless you are overtaxing the processor, or you schedule a routine to "update" less often, the game "loop" is going to execute 60 times per second. Assuming the routine that moves your sprite is ...


4

It's quite simple actually: cocos2d javascript is the join up of cocos2d-x's JSB and cocos2d html5. It's just a name given to that mix up. JSB is a set of Javascript native function overwrites that, when interpreted by the necessary scripts, are converted to their native correspondents. And these native functions are interpreted by the compiler, resulting ...


3

Your image example doesn't fit reality for the card you have shown. You are showing the wrong corner, but that's just me pointing out little things ;) I will give you the simplified version for being able to flip an area that's a triangle. Calculate the x and y offset from the bottom right corner. (it's the difference between the world coords of the ...


3

It's late in the day, but 71Squared has now released a command line app for Glyph Designer that allows you generate your font assets as part of your build process and also specify the size you would like, so you can automatically generate SD/HD output as required by your project. http://www.71squared.com/en/article/1979/introducing-glyph-designer-command-...


3

It's true that each image has an irregular shape, but you don't need to snap that shape. It also does have a bounding box, and you know where that bounding box should be in the solved puzzle. Note that those bounding boxes can collide but it doesn't matter at all! so you just need to check if the bounding box almost as it's rightful position, and if it is, ...


3

No, if you are referring to writing Objective-C using the Cocos2D framework to do animations, your animator will not be able to do so without xCode. He could write the code in a text file and pass that to you, but will not be able to compile them to check that they do work (which really defeats the purpose I suppose.) However, if you only need sprite ...


3

Number 3 is easiest if you have an image that is tileable, meaning that if you put them next to each other you wouldn't be able to pick out the seam. Then you can draw the same image twice once on x,y and once on x+image.width,y. each frame you decrement x until x < -image.width where you add image.width to it. Adding details is easy by drawing some ...


3

I'm not finding any way to do this within the cocos2d framework, so if someone can do that it would probably be a better answer. However, cc.Texture2D does have a getHtmlElementObj() function. Now, this function can return either an image element or a canvas element. If it returns an image, you need to make a canvas from it as shown in this answer: var ...


3

Use this code (cocos2dx v3.x): node->runAction( Sequence::create( Spawn::create(A, B, nullptr), C, nullptr)); This is what happen: A and B start simultaneously After the longer one finished, C start. Important: Remember that you should use finite action when using Sequence. for ...


2

The catch of Game salad is "write games without coding...". However it doesn't mean write games without programming! Just because you aren't coding doesn't relieve you from knowing the math and logic real programmers have to go through when developing apps!


2

As I understand you need the Gamedev Animation Studio. I use it to animate sprites. This tool interpolate the animation between keyframes by various characteristics of sprite.


2

Since version 2.1 cocos2d-iphone integrates JavaScript bindings. More details: https://github.com/cocos2d/cocos2d-iphone/wiki/cocos2d-and-JavaScript You can find a game done with JS here: https://github.com/vlidholt/CocosDragonJS


2

I'm making an assumption that this is the Cocos2d-iphone branch. Cocos2d allows you to schedule an update that happens every frame, just like a game loop. If you schedule this update on your scene or some base layer/node that always exists, you can carefully execute your AI actions first, then check/update your game state. I find this to be a really good ...


2

I agree with Engineer's answer, where the main point is "don't fight the framework". Games are different However, another point I want to add is that when it comes to software, games are different. Even though the article is a bit outdated by now, I want to quote a part from Joel's five worlds of software programming: Here’s an important thing to know. ...


2

I found my solution by creating subclass of PhysicsConnector. public class CustomPhysicsConnector extends PhysicsConnector { private float flagDisplacement; public CustomPhysicsConnector(IShape pShape, Body pBody, boolean pUdatePosition, boolean pUpdateRotation, float flagDisplacement) { super(...


2

You have to implement GKAchievementViewControllerDelegate protocol in your layer or scene. Declare your layer like this: @interface MyLayer : CCLayer <GKAchievementViewControllerDelegate> This will show the game center: - (void)showAchievements{ NSLog(@"Show achievements!"); AppDelegate *delegate = [UIApplication sharedApplication]....


2

It depends on your implementation. A. You can keep tile size constant (e.g. 64px). This way depending on screen resolution the number of tiles that fit on the screen will change. And of course you will need to take care about retina displays, cos they have very high pixels-per-cm density. B. You can scale your tiles to preserve constant physical size (e.g. ...


2

You could simplify the checks by calculating the squared distance from the center of the explosion to each corner, then comparing the minimum squared value to the square of the radius to see if there is an overlap. If so, then calculate the square root of the minimum distance to calculate the percentage of damage. However, your code looks efficient enough, ...


2

Check this blog post of "Master" Steffen :). It seems to be all about OpenGL draw calls and OpenGL state changes of the images and how large the images are and if they have transparency or not. Try to use several "big" background images in parallax and compare the fps rate with or without batchnode. Following I report some extracts from Steffen's post ...


2

This question is several weeks old, but I thought I would answer in the event you were still looking for assistance, or too perhaps help someone else down the line. Please note that the way you are loading the spritesheet using CCSpriteFrameCache is correct, but it does nothing more than add the contents of the spritesheet to memory. You then need to ...


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