Hot answers tagged

10

I found the implementation description from the author of this effect: It surely was a lot of work to create the depth illusion in a 2D plane. The principle is very easy though: circles start in the middle of the screen with scale 0. Then the first circle of the tunnel starts scaling proportionally to the time elapsed (linear scaling doesn't work) and after ...


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

I actually found a simple solution! Changed the character objects to not only include info and sprite, but also a CGPath. Then implemented a method, to loop all character objects, and check for CGPathContainsPoint( params ...) instead for CGRectContainsPoint( params ...) Tutorial I used: http://www.youtube.com/watch?v=HxHZwzaadNQ - "The magic of CGPath"...


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

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

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

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

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

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

I'm not sure what the best way to do this is but the way I would do is by putting all the children into an array. Then iterate trough the array: WhateverYouNeed *thingInArray; CCArray *theArray = [self children]; for thingInArray in theArray { if ([thingInArray tag] == whateverTheTagIs) do some stuff to thingInArray }


3

This is what you're doing wrong: glUniform1i(textureLocation, GL_TEXTURE0); glUniform1i(guideLocation, GL_TEXTURE1); Instead of GL_TEXTURE0 and GL_TEXTURE1 you need to give them 0 and 1, like so: glUniform1i(textureLocation, 0); glUniform1i(guideLocation, 1); Also, when using shaders you don't need glEnable (GL_TEXTURE_2D), or the corresponding ...


3

It's very simple. Which is your primary goal: learning or time to market? Avoid using a library if your primary goal is to learn from the experience of implementing the concepts that are solved by the library. Whenever I develop a game (part time), my goal is purely learning. I don't care how long it takes, thats why I'm doing it all from scratch! Now, you ...


3

I'm unfamiliar with objective C, so I can't give any specific code. But the general way to accomplish things like this is by doing a per pixel collision check. Basically it works just like how you have it based on the rectangle, but before firing the touch event, you have to loop through all the pixels that were touched and make sure at least one of them ...


3

Initialise and assign a movement function to each enemy as a function of time for e.g. x(t) = 5 * sin(t) y(t) = t * 0.2 final position = Point(x(t), y(t)) when they start flying, plug in the game elasped time since start of flight into x(t) and y(t) to give you the new X and Y coordinate of the enemy. A boss movement function could be e.g. x(t) = 10 * ...


3

After hours of doing weird stuff (like creating an app that hides the window and terminates itself upon load just to make it appear like a command line app), it turns out the solution is too simple. Create that CCGLView yourself. Duh. Steps to create a skeleton cocos2d command-line application Xcode project: (Note: I'm using cocos2d 2.x, so if you're using ...


3

When you detect the absence of a touch (I'll leave that to you), reset your rotation value to 0. Then any further change left will go left, etc. If you want to do this when the user is continuously touching the interface, I think your question represents bad control design. If the user, even for an instant, moves their finger in a direction away from 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

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 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.


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