Tag Info

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


9

There's a very easy solution for that particular example. I'm assuming your arbitrary shape is just a series of points. Draw a ray from each of your objects in any direction. If the number of times it intersects a line segment on your shape is even (including zero), you are outside of the shape. If the number of times you intersect is odd, you are inside ...


7

If you're going to use a perspective camera like that, you're really not saving anything by using a sprite sheet. I mean I guess you could render all of the potential walls in one quarter of the screen and then do mirroring for the other 3 quadrants, but that assumes a stationary camera. Why would you want to use a sprite sheet anyway? You're not really ...


7

From the image you posted it looks like the only thing you did wrong was the order in which you applied the scale and rotation to your transformation. I don't have any experience with Cocos2D but I just mocked it up in XNA and here are the results: And here's the transformation matrix I used in XNA. See if you can find any correlation to your code: ...


7

That method of moving a player left and right is a little bit complicated and can be done in a much much nicer way using a simpler class design. Create a player class and declare cgpoint vel and pos. You will also want a CCSprite in the header file of this class: @interface player : CCLayer { CCSprite *spriteName; CGPoint vel; CGPoint pos; } ...


6

There's an article on GDNet about walls and shadows in 2D; the technique can be applied to visibility determination as well. Additionally there this old-school post on 2D visibility, this post on StackOverflow and a variety of other resources online you can find via Google. Once you have a logical understanding of the visibility region for an agent in your ...


6

Scripting is generally used in bigger projects to allow non-programmers to easily add content to the game. This can be new quests, interfaces, gameplay for levels, etc. A scripting language in itself shouldn't be difficult for a programmer to learn, what will take time is the integration into your game framework. Whether it's worth it or not is really your ...


6

Here's an explanation of the keys. frame The sprite location within the sprite-sheet as position and size values. offset Most of the current texture packing tools remove transparent areas of the image before they pack it. Imagine you got a sprite with the size of 100x100, but on the left and right there are 4 columns of totally transparent pixels. The ...


5

There has been a lot of discussion on this very topic on the Box2D forums. You'll find most of the info under the guise of breakable bodies, which is your problem in reverse. Here are my suggestions in order of easiness: Depending on the situation you could just change the animation of the main character to show that he is now carrying the item without ...


5

Lag results from the speed of light limitation, and the processing speed of network protocol translation and switching in intermediate networking devices and at end points. From yours and your players' point of view, these are invariant factors. Game that deal effectively with lag do so by adjusting player perception of the impacts of lag. One example is in ...


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


5

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


5

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


4

Here is the way generally followed to sub-class a CCSprite. public class CharacterSprite extends CCSprite { // Add new custom fields or methods here, // or override the specific methods of CCSprite // that you want to extend the functionality of. } From your question I can understand that you are inheriting CCSprite ...


4

Both are valid choices, but with Unity3D it's going to be much simpler to achieve what you want, mainly because: Unity3D has a much easier content-pipeline. You can simply drop a lot of different image- and 3D formats into Unity and work with them, while cocos3d requires models to be in PowerVR POD format. Unity3D has/is a visual editor, which makes it ...


4

There are numerous ways of smoothening a rotation. If there is any physical meaning to it, we'll need to know what that is, but if you are merely doing it to make it appear less jerky, it is pretty arbitrary. Note that unless you know what the velocity is going to do in advance, any attempt to smoothen the corresponding rotation will cause it to lag behind ...


4

There are several ways to go about this. Here are some ideas: Pre-rendered animations Use a 3D rendering and animation software to animate 6 different die rolls. The advantage of this is that you don't need any 3D library, as you can show the rendered animations in a 2D context. Also pre-rendered animations give you lots of artistic freedom. In your game ...


4

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


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


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


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


3

It's often better to prefer composition to inheritance. In this specific case, I would strongly advise against using inheritance to arrive at a solution. What you are trying to do is take a sprite, which is naturally a rendering entity, and inject into it some methods and data for handling responsibilities outside its domain -- namely what sounds like AI ...


3

Use the XCode debugger and do a stack track to see the last line of your code where the crash happened. That should give you a clue on what is causing the error


3

You could port the Box2D SVG parser implementation from the Box2D forums (you said that you have experience with AS3) . http://www.box2d.org/forum/viewtopic.php?f=8&t=3073 It doesn't look bloated to me.


3

To reduce the amount of if statements you have you need to make your solution data-driven instead of manually adding logic for each UI component that needs to interact. You could do this by storing your buttons data (such as each buttons bounding box and state) in an array of structs or a NSArray (or NSMutableArray) of classes. Then when you receive a touch ...


3

Use the first one. You certainly don't want your timers be called in random order. Although I'd suggest to actually use none of them, but use the standard update method of cocos2d. This will give you the best available performance and consistent behavior.


3

Sure, I had to figure that out for my game Star Catch. There may be better ways of doing it but this is how I did it. I actually found the algorithm online (sorry I can't remember the source) I did a search for detecting a point inside a polygon. I created a NSMutableArray to hold my point. I add the points in my touchevents. - (BOOL) ...



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