8

You could think of individual places as "rooms" with "doors" connecting them: To implement this, you could create a struct Room to hold a room, with fields for a set of items currently in it and what directions its exits lie in. Then simply keep an array of all rooms and have a pointer to the one the player is currently in. There are ways of getting extra ...


8

This is a very interesting topic. You can build the water effect using SpriteKit and its integrated physics engine. Step 1 Create a Physics World Create many little circular SKSpriteNode(s), each one will have a circular physics body matching the graphics representation Step 2 Then every frame you'll need to: Draw all the sprites on a buffer Apply a ...


5

Plugins for Unity can be written using Objective C; refer to this page: http://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html However I wouldn't assume that a code library of thousands of lines that wasn't designed to be used as a Unity plugin will work as a Unity plugin. It's all free so you could download Unity, fire up the demo project, and ...


5

Your question is a good one. I've had exactly the same question regarding SpriteKit and have been very confused about the lack of information on the web about this. SpriteKit seems to encourage you to put all of your Model-View-Controller code into the same class (your SKScene subclass), which is really confusing to me. How would you ever build a game of ...


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

Ok, let's go at this in a multi-stage fashion: Room representation Before we can do anything else, we need to consider how to represent the rooms internally. This is just a rough thumbnail sketch, refine as necessary: @interface TARoom : NSObject { NSDictionary *_links; // Contains neighbouring rooms. NSString *_identifier; // This will become ...


4

One method is to have the head define a trail as it moves and position all other nodes at positions along this trail. In this method you need to define the position of the body parts as a constant distance along the snake from the head. So on each frame you want to; update the position of the head. add the current position of the head to a list of ...


3

There's a special class available in cocos2d that renders a ribbon of quads for you. At one point it was named CCRibbon, but I think it has been changed to CCMotionStreak (docs). It's designed to render trails or ribbons. I think using that class would be the most efficient way to create such an effect.


3

Last time I used the Facebook API they didn't provide any multiplayer or gameplay functionality. I'm pretty sure you have to write that yourself. You can still leverage the Facebook API to publish scores/achievements and find friends of a user. Eg. You can get the user-names, profile pictures from FB and also use the Facebook API to post something on the ...


3

If I understood you correctly, you only want to know whether two tiles, specified by their 2D offset coordinates, are adjacent or not. For any question related to hexagon grids, I'd recommend to refer to the Hexagonal Grids page by Amit Patel. It contains the mathematical backgrounds as well as excellent animated interactive examples, and probably ...


2

The way to deal with this is to set a timer once the person taps the phone. The most user friendly scenario that you'd implement would look something like this: When you detect a tap, set a timer (t = timeToRepeat) On each frame, decrease the timer by dt If the timer reaches zero, move the sprite a tile and reset the timer If the user releases their finger ...


2

It all depends on how flexible you want to be. I dont think the approach you suggested is bad, in fact its one of two main possibilities i would consider in your case: store a list of checkpoints that the NPC walks through (once it reaches the last checkpoint it goes back to the first and repeats). Once arriving at a checkpoint, the NPC will find the best ...


2

For my system I use an EntityDirector class. This takes care of common entity tasks, like tracking available entity IDs, reusing removed entities to save allocations, creating/deleting entities, adding/removing entity attributes and so on. However, there are more specialized classes for different tasks. There's a SpatialEntity manager that has ...


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

You want to try and avoid inter-mingling objective-c and c++ as much as possible, it will create code that is very hard to debug and even harder to understand by others potentially joining your project. It is essential that you ground a sense of framework and work in a modular fashion in respect to how the platform wants to you to interact with objective-c ...


2

General advice is to start with the switch statement. At some point you may notice that you're writing a lot of very similar code in different 'case' blocks within the switch statement. If and when you notice that, that's the time to refactor the code so that those similar cases can be coalesced into a single block. Until then, go with the switch ...


2

Take the resulting vector Dir from subtracting the start point from the end point. Now use atan2(Dir.y, Dir.x) to get the angle of the vector (angle between positive X axis). Use that angle to decide the direction of the swipe. Include your dead zones as desired. You can easily utilize something like this answer. Where your direction could be: enum ...


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


2

Using decorators is not a good idea in this case, because you also want to un-equip items. When you wrap decorators in decorators in decorators and then want to remove a specific one inside that stack, it's a quite messy operation (especially because an object shouldn't be aware that an object it uses is just a decorator wrapping something else). What you ...


2

One alternative that avoids lengthy switch statements all over the program would be to define inside your Skill interface additional components that define its behavior. These components would be implementing an interface as well. For example, all skills might contain an attack behavior, which could look like: IAttackBehavior attackBehavior; Creating an ...


2

As mentioned in the answer you reference, this is sort of the artistic side of procedural generation. These are the kind of functions you just have to keep tweaking until you get something that works for you. Everyone is going to have different ways of generating terrain and even a number of different ways to generate noise. It's unlikely there's going to ...


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

If the only difference between the enemies are sprite changes and simple quantities (number of shots fired, rate of fire, etc), multiple classes would not be needed. This is exactly the sort of game Sprite-Kit was designed to make easily and quickly. Classes would be more appropriate if there was some unique behavior between the different kinds of enemy ...


2

I've implemented the kind of smooth snake movement that you explain. It's actually quite simple, but most of the examples I found while looking were the same kind as you encountered. And I don't think it's as easy to explain in plan words. As you can see, my snake is a bit unusual, thats why providing implementation here is not really optimal. But I think ...


2

First you need to know what is an ellipsoid and why we use them. The earth is spherical and to be exact it can be approximated using an ellipsoid. Location Service and all GPS system that work world wide, must use an ellipsoid that fits the best way the earth, Why we need an ellipsoid? because we need a mathematical model to do the computations. for ...


2

For a 2D puzzle game for iPhone and iPad, SpriteKit would be the easiest way to do this. SpriteKit is made especially for developing 2D games. You don't have to bother creating a scene graph, how to draw images to the screen or how to create a game loop. It is already there, ready for you to use it. Start with creating a new project from the Game template ...


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

Maybe try giving the objects and/or the plane some friction: btRigidBody::btRigidBodyConstructionInfo info(1.0, motion, boxShape, inertia); info.m_friction = 0.9f; blockRigidBody = new btRigidBody(info);


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