Tag Info

Hot answers tagged

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


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

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.


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

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

This also largely depends on how your character class is setup. Assuming we're using direct references here, I would actually refrain from storing your stats directly. Instead I might have the following: int Player::GetStrength() { return _stats.strength + equipment.GetStrength() + buffs.GetStrength(); } int Equipment::GetStrength() { return _head.strength ...


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

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


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


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


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

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


1

I'd probably try to do something like the following: Store all your vertices as well as the edges connecting them. When an explosion happens, do the following: Remove all vertices within the explosion radius. Remove all edges within the explosion radius. Flag all vertices with removed edges as "dirty". After an explosion, iterate over all "dirty" ...


1

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


1

Here's some very crude code to roughly illustrate a potential solution: if(object.grabStart){ vec3 startRot = object.transform.rotation; object.startRotReference = startRot; } rotation += 5; object.RotateXYZ(rotation,0,0); if(object.transform.rotation.x >= object.targetRotX) object.RotateToStartRot();



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