Simple iPhone accelerometer ball-maze game - iphone

I want to make a simple 2D game where the user has to navigate a ball through a maze (using the accelerometer of course). I used a simple view to make use of the accelerometer and move a ball on the screen. Now how do I go about building the maze? Would I have to use cocos2d or something similar? How do I make the ball stop or rebound when it hits the wall of the maze?

Check out this game... it does a great job with the accelerometer and also setting boundaries.
http://github.com/haqu/tweejump

This one is for Android rather than iPhone, but it has some parts that are very relevant to your project, such as moving a ball. Does not include ball rebounding or building a random maze; it loads mazes from a file.
Amazed
For ball/wall bouncing, try this question.
For generating a maze, see this question.

Related

iPhone iOS how to create a room for an iPhone game demo?

I'm building an iPhone core motion game demo and would like to have a virtual "room" around the user. The user would be using the phone with the core motion to "look around" the room through the phone. Attached is an example.
I'm not looking for anything fancy. 4 solid color panels for walls and 2 panels for the floor and ceiling would do. Pretty much a large cube with the middle at the user's location
What is the quickest way for me to create a room with a box geometry, putting the user in the middle? Can this be done with UIKit objects, or do I need to use openGL to render the panels? Maybe there's some kind of a game engine that I can use for these purposes?
I would want to rotate the room in the future.
Thank you for your input!
You won't be able to create a 3 dimensional environment without using OpenGL in some form. The best way to get started is to follow a good tutorial on OpenGL such as this one. You could even take this tutorial and put the camera inside the cube and voila, instant room. You would just need to add view rotation logic from core motion and you would be set.

Bouncing Particles in a CCParticleSystemQuad

I'm using cocos2d to make a game on iOS. I have a particle emitter that I want the particles to bounce when they hit the bottom of the screen. Thing is I cannot seem to find a way to do this and with my limited understand of open GL the answer my be obviously in front of me but I don't see it. Is there an example of this or a way to use the CCBounce or box2d or something?
Here is a bouncing ball tutorial which uses cocos2d + Box2D:
http://www.raywenderlich.com/457/intro-to-box2d-with-cocos2d-tutorial-bouncing-balls
There is also EaseBounce actions (CCEaseBounceIn, CCEaseBounceOut, CCEaseBounceInOut) in cocos2d for you to run on sprites. See "EaseBounce actions" section in "cocos2d Programming Guide: Actions - Ease".

Problem in using CCCamera

I am going to work on a game project. I am using cocos2d. I want to use cccamera class of cocos2d. Please tell me about any tutorial on cccamera. I want to implement more or less like angry birds, throwing the ball that reaches its destination facing the obstacles in the way.
So when the ball moves ahead the scene accordingly moves back depending on speed of the ball.
How to manage all that. I think i should use cccamera.
Thanx.
CCCamera, per the documentation is used for 3D effects (http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_camera.html) and recommends the use of CCFollow (http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_follow.html) for 2D related effects (such as following the birds forward, etc).

How can I calibrate the accelerometer?

I'm using the accelerometer to move an object on my screen.
It's only working when the iphone is flat.
If I use the iPhone in another position, the object is not moving like I want
(the Y axis is not well managed).
So, I've to calibrate the position of the accelerometer, I guess.
But I've no idea how to do this.
Please help me.
Thanks in advance.
Regards,
ALpesH
hi hope all is well.
A simple google search came up with this beautiful post.
It is exactly what you wanted. A tutorial on Accelerometer Calibration & Optimizations.
This tutorial assumes you know the basics of the accelerometer. If not there are plenty of tutorials on google that will help get you accustomed to the accelerometer basics.
This tutorial will focus on 3 things:
Calibrating the accelerometer so the user can play your game from any
position.
Changing the "sensitivity" of your object's movement.
Adding the option to "invert" the controls.
First off, why bother adding these features? Simple. Launch your accelerometer based game and try the following tests:
Play sitting up in perfect position.
List item
Play it slouched over.
Play it lying down on your side.
Play it lying on your back with the device parallel to the floor and
the screen facing you.
Obtained from this website:
http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/39833-tutorial-accelerometer-calibration-optimizations.html
Let me know if this helps if it does choose this as the answer.
Other than that if you need any more help let me know
Ive implemented this tutorial code in my own app and i am not playing a simple ping pong game upside down and also playing it on the side whilst lying on the bed. :D
Pk

iPhone: Camera following player in cocos2d

I'm making an iPhone game in cocos2d.
I was wondering how I would make the camera / the view follow a specific sprite?
would I use the CCCamera class?
Yes, CCCamera would work. However, it has some drawbacks that make it undesirable for some uses. Moving the layers respectively all other objects relative to that sprite may be a better solution. It depends on the game.
First, read up what the different approaches and their drawbacks are, you can get a lot out of this cocos2d forum thread:
http://www.cocos2d-iphone.org/forum/topic/5363
It would be helpful if you could describe what your game is about and why you need the camera attached to that sprite.
For example, if you're thinking of a running game like Canabalt, i would not use the camera to scroll over the world, but instead scroll everything relative to the player (towards him) with the player sticking at about the same x coordinate while running. Perfect examples of games where you would not move the camera at all are the iCopter games, they are basically simplified versions of Canabalt. Notice that the player sprite always stays at the exact same x coordinate, and the game world just scrolls
Scrolling the camera itself in my opinion makes the most sense if you have a large game world that the player can traverse in all directions, and the number of objects are simply too numerous and also moving about in various directions, so updating their positions individually each frame would be both overkill and prone to errors. And since the game world is so huge, you would want to use the camera's position to limit what is drawn on screen.
use CCFollow actions
Like these :-
[self runAction:[CCFollow actionWithTarget:(u r hero) worldBoundary:CGRectMake(0,0,1050,350)]];
it will helps