Hot answers tagged cocos2d-iphone
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) ...
6
After a few days of researching, I found a solution to this particular transform. This is much more mathematical than program-oriented. Therefore, I will be using pseudo code.
Now, given a screen coordinate (x,y), we first want to represent (x,y) respected, or fixed, to the world, not the screen. For example, my game use the top-left most corner of ...
5
On iOS there are two different units of measurement. Points and Pixels. On older devices a point is equal to a pixel. On new devices, there are two pixels for each point, both vertically and horizontally (so totally 4 pixels per point). An iPhone 3 has 480x320 pixels and 480x320 points. Whereas an iPhone 4 has 960x640 pixels and 480x320 points! The important ...
5
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;
}
...
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
There are various scaling algorithms that are specifically crafted for enlarging pixel art for modern displays. They usually work with factors 2x or 3x and produce nice non-blurred and non-blocky results.
Take a look at this Wikipedia article, which has many examples.
4
Given the options in your question, separate timers would be the best approach.
I'm not sure what your implementation of the "timers" is but you can get a major performance increase and simplify things by using a different approach. Rather than using timers (as in stop-watch type timing) you could use time stamps that represent the expiration of a cooldown ...
3
Since you're using static patterns for breaking the image up, you can use static defined rectangles too. Simply pre-define the bounds for each rectangle by manually checking the placement for each. As shown in the image I gave you before, the rectangles should just be the minimum size required to enclose each shape.
3
Like Amplify91 said, it's not recommended to depend on a fixed framerate, even for an offline game. It's best to keep the game logic and rendering logic separated.
The game logic updates the objects positions, statistics, and check for collisions and responds to inputs, and that is independent of the framerate because it's called at regular intervals. 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.
...
3
If you are a developer "through and through" reconsider hiring an artist, and don't be afraid to look in non-traditional places.
I know when it comes time for me to throw away the place holder graphics and get more serious, I will be going to the Art Departments of colleges in my area. I know a few Art Students who would love to help with the design of a ...
3
Usually you'll just create one scheduler that calls the update method of your world/game. There you iterate through all entities/sprites and call their update method.
This gives you much better control about the flow of your code. You'll be able to run the physics-simulation first and then iterate through all bodies/sprites and update their position.
...
3
It is possible to separate the render thread from the update thread, but it is quiet difficult to make. You'll need a triple-buffer of the render state. For an explanation of the problem and solution check out:
http://blog.slapware.eu/game-engine/programming/multithreaded-renderloop-part1/
...
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
First of all, given the grid sizes you've talked about you're not likely to run into performance issues with your current implementation, so if you're asking this because you have a performance problem this may not be it (and you should profile). That said:
The "array of arrays" approach might seem like a reasonable representation of a grid (and to some ...
3
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, ...
3
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 ...
2
Glyph Designer is pretty good. It's easy to use and the results are nice, they do a good job with options for outlines, shadows and gradients and the fonts look good enough that I have come to prefer using bitmap fonts generated by Glyph Designer over TTF fonts even in places with static text that are not performance-sensitive.
It has a few annoyances, like ...
2
What you could do is determine where the character is within the viewport and only move the camera up if it is within (say) the top 20% or down if it's within the bottom 20%. Take this image for example:
The red and blue lines here represent the spot where the player would move the camera. For example, when the ball's position hits the red line, the camera ...
2
I would let the ball move in the camera-relative y plane within a certain range. Say the screen is 100px tall (I don't recall the actual specs); if the ball's y is above a certain threshold, maybe 70px above the bottom of the screen, move the camera up with the player. If the ball is below 30px, move the camera down with the player. Otherwise just keep the ...
2
If your vector is a vector of floats, where each consecutive pair of floats represents a single vertex, as suggested by your glVertexPointer call, then it should surely be v.size()/2 in glDrawArrays, but I'm not that sure this would cause your error, otherwise some more information and code would be required.
2
I would go with this method:
draw the ball object,
then draw the particles over it with alpha blending enabled
redraw the ball in exact same position but this time use lower opacity for the whole sprite (maybe something around 40%)
This way you'll both see the ball everywhere even if no particles are drawn at that pixel(caused by the back ball picture), ...
2
Iterative empirical testing. Add some test sliders to your GUI that control the force applied for the upward and downward directions.
Other than that, consider changing the way force is applied. Add gravity into the mix, when the plane is horizontal its lift offsets gravity. The lift decreases with change in pitch. Your force is always forward, when ...
2
Once you have implemented some touch delegate you can easely tell if you touched your sprite or not using bounding boxes, doing something like:
if (CGRectContainsPoint(touchPoint, [sprite boundingBox])){
}
2
Probably the most robust way is to store a linearly-growing gameTime value that you can update by just adding the delta to it each frame, then set gameSpeed = someConstant * pow(gameTime, 3.0) each frame.
But if you want to be able to do something interesting like changing the power continuously in real time, you could use the derivative: if y = t^n (in ...
2
You have to make sure your sprite-rectangle is always within the screen bounds.
You can ensure this by clamping the x, and y position of the sprite within the screen bounds.
Something like this (this is assuming the anchor point of the sprite is at its center, which is the default):
// move sprite using accelerometer
// get screen size
CGSize screen = ...
2
You can use any format that's convenient to you. plist works fine as you can easily parse it into data-structures without the need of external libraries. Also something like JSON or plain CSV would work. If you write a level-editor yourself, you can use any of these formats.
You don't have to write the level editor yourself though. Since your game is ...
2
Let's consider the basic slingshot mechanism that seems to be implemented here.
We know the user can drag the slingshot by defining a vector having its origin at the tip of the downward pointing triangle (like in my figure). The user can define thus vectors that point toward the bottom of the screen (restricted programmatically), and whose radii cannot be ...
2
One way would be to read as binary and parse from that.
for example: (Assuming you have a 8Bit wav file)
//Get your file
Load wav into buffer
for each 8 bit chunk convert to unsigned Integer
add to array.
//Generate image
for each Integer scale it down to half your image size
draw pixel wide line from center to top from scaled result.
Draw a mirror ...
Only top voted, non community-wiki answers of a minimum length are eligible
