I saw the Cocos2d credit on the menu screen for Racer by Tatem Games
http://www.tatemgames.com/tatem/games/racer/racer.html
and was curious how they did the scene scrolling for the road and the sides.
A fast, easy to use, free, and community supported 2D game engine
I saw the Cocos2d credit on the menu screen for Racer by Tatem Games
http://www.tatemgames.com/tatem/games/racer/racer.html
and was curious how they did the scene scrolling for the road and the sides.
Racer has a really nice into the screen scrolling perspective, I'm really interested to find out how that could be done with cocos2d. Thanks for contributing your ideas!
If you are curious what I'm talking about, download racer lite and try it out.
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=327239734&mt=8
i am interested in that too. Anyone please help us in right direction.
Thanks
I think this effect is a lot easier to achieve than you may think. Notice that you never get to see the horizon when racing in this game. I hink his can be achieved in Cocos2D by changing the position of the camera which gives you that perspective. I have not personally used the camera but a number of people on his forum have.
i have following doubts.
1. how to add random car in the track? Is it random or predefined? If lets say i create multiple levels than should it be predefined or it should be random?
2. How to add 3D perspective to 2D game?
Thanks
hey... i'm 99% positive that you can get the perspective effect you're after using the camera, specifically the eyeX, eyeY, eyeZ properties....
so do something like this.... you'd be doing it to your scene object:
float someXValue;
float someYValue;
[myScene.camera setEyeX:someXValue eyeY:someYValue eyeZ:415];
i'm not sure right off what values you need to use in there, but they're openGL values for the openGL based camera, so read the following and that may help...
http://www.opengl.org/resources/faq/technical/viewing.htm
And i may be wrong on some points here, but this should get you in the general ballpark of what your after for the perspective (anyone, please correct me if I'm wrong here about anything... thanks!)
That perspective isn't that hard to recreate in cocos. The camera in cocos is based on gluLookAt, which you have to understand a bit to get this perspective.
void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz)
gluLookAt has 3 components, the eye is the position of the camera, the center is the postion where the camera looks at and 'up' is a normalized vector telling which direction is up. Think of the up vector as a big arrow on your head which is pointing upwards. So when moving in the xz plane the positive y axis is up (0,1,0). When lying on your back in the xz plane and looking to the sky the up vector would be the positive z axis (0,0,1).
Since cocos uses the xy plane, you need a camera positioned in a plane parallel to the xz plane which looks up (or down) to the xy plane from a distance. In my case I've used a negative y and postive z position for the camera. The up vector is then the positive z-axis. That way you get a 3d projection where the camera looks over the xy plane.
If you experiment with the eye and center of the camera you'll get that perspective easily. You can use the TMXorthoTest (located in tileMapTest.m) from the examples to test it out quickly. Gook luck!
You must log in to post.